Results 1 to 6 of 6

Paste Excel Range into Word Doc at certain place

Threaded View

  1. #1
    Registered User
    Join Date
    09-14-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 365
    Posts
    26

    Paste Excel Range into Word Doc at certain place

    Hi,

    I have the following VBA code which copies a range from Excel and pastes it into Word. Currently, the range is essentially pasted in the top left corner of the Word doc. It does this perfectly. However, I'd like to instead paste the table in a specific place. I've attached a sample Word doc and noted where the table should be inserted by writing "Paste Range here." For the record, that place seems to be the 31st line of the doc.

    Thanks in advance, I really appreciate your help.

    Sub CopyXLStoDOC()
    
        'declare local variables and constants
        Dim oDoc As Word.Document
        Dim oWord As Word.Application
        Dim rRange1 As Range, rRange2 As Range
           
        Const sDocPath As String = "" 'if you wanted to open an existing Word doc, the address would go in between these quotes
     
        
        'set ranges to copy
        Set rRange1 = Worksheets("Sheet1").Range("A1:C10")
    
        'open the Word document, if it doesn't exist, then create one
        On Error Resume Next
        Set oDoc = GetObject(sDocPath)
        Set oWord = oDoc.Parent
        If Err <> 0 Then
            Set oWord = CreateObject("Word.Application")
            Set oDoc = oWord.Documents.Add
        End If
        oWord.Visible = True
        
        'copy and paste first range into Word
        rRange1.Copy
        oDoc.ActiveWindow.Selection.Paste
        
        'Clean up objects
        Set oDoc = Nothing
        Set rRange1 = Nothing
        Set rRange2 = Nothing
        
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Paste excel range into word -> how to center the table in the page
    By d82k in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2013, 03:45 AM
  2. Macro to copy and paste an excel range into a word doc and then print to PDF??
    By Weswold in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-01-2012, 11:34 AM
  3. Macro to Copy from Excel and paste to a specific place in word
    By tjynyc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-14-2012, 01:01 AM
  4. Copy Range from Excel and Paste it in MS Word and then save it in a specified path
    By prasadcherry in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2012, 02:29 PM
  5. Extract a text from word and place it en excel or word?
    By Elegidos in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2009, 06:14 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1