Results 1 to 4 of 4

Thread: [RESOLVED]Copying an Excel Column to a Word Doc

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    103

    Resolved [RESOLVED]Copying an Excel Column to a Word Doc

    I have a series of Excel spreadsheets, each with multiple worksheets.
    I'd like to copy a certain column (user-defined) from each worksheet on the spreadsheet and paste it to a word doc, with the name of the worksheet above each copied column (the columns become tables when pasted to Word).

    The contents of the clipboard seem to get lost when moving between the two applications. What would be the best way to transfer the data from one program to the other, retaining the cell-style layout?

    What I have so far is:
    VB Code:
    1. Sub CopytoDocument()
    2.  
    3.     Dim cColumn As String
    4.     Dim WordObj As Object
    5.     Dim CellContents As String
    6.     On Error Resume Next
    7.     Err.Number = 0
    8.    
    9.     Set WordObj = GetObject(, "Word.Application")
    10.     If Err.Number = 429 Then
    11.         Set WordObj = CreateObject("Word.Application")
    12.         Err.Number = 0
    13.     End If
    14.    
    15.     cColumn = InputBox("Which column (indicate the letter)?")
    16.     Columns(cColumn & ":" & cColumn).Select
    17.    
    18.     Selection.Copy
    19.     'CellContents = Selection
    20.    
    21.     WordObj.Visible = True
    22.     WordObj.Documents.Add
    23.    
    24.     Selection.Paste
    25.    
    26. End Sub
    Last edited by pickarooney; May 12th, 2005 at 09:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width