+ Reply to Thread
Results 1 to 6 of 6

Paste Excel Range into Word Doc at certain place

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

    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.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Paste Excel Range into Word Doc at certain place

    This is one way to do it...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Paste Excel Range into Word Doc at certain place

    Another way would be to put a 'placeholder' table into the document and use code like:

    Dim wdRng As Word.Range
    Set wdRng = oDoc.Tables(1).Range
    wdRng.Tables(1).Delete
    wdRng.Paste

    where the 1 in 'oDoc.Tables(1).Range' is the table's index # within the document (it's always 1 for 'wdRng.Tables(1).Delete', though).

    With this approach, you can replace the table as often as you like.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

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

    Re: Paste Excel Range into Word Doc at certain place

    Thanks for the help guys! The first option seems easier for what I need, but it's still not working. Even with this change, the table is pasted at the top of the document. I replaced this section of my code:

    Please Login or Register  to view this content.
    with:

    Please Login or Register  to view this content.
    The text "PASTE TABLE HERE" is definitely in the Word doc that Excel opens. Still not working...what am I doing wrong?

    If I use the second option (macropod), how do I know what the table's index # is?

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Paste Excel Range into Word Doc at certain place

    Quote Originally Posted by v.edwards.jr View Post
    Thanks for the help guys! The first option seems easier for what I need, but it's still not working. Even with this change, the table is pasted at the top of the document. I replaced this section of my code:

    Please Login or Register  to view this content.
    with:

    Please Login or Register  to view this content.
    The text "PASTE TABLE HERE" is definitely in the Word doc that Excel opens. Still not working...what am I doing wrong?

    If I use the second option (macropod), how do I know what the table's index # is?
    It looks like you did it right. Not sure why it doesn't work.

    Another method is to set a bookmark (named PTH in this example) for the "PASTE TABLE HERE" text in your template. Then use this code.

    Please Login or Register  to view this content.

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

    Re: Paste Excel Range into Word Doc at certain place

    The bookmark idea worked, good call AlphaFrog! I really appreciate your help.

+ Reply to Thread

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