+ Reply to Thread
Results 1 to 6 of 6

How to copy word table from one word document to another word document using excel vba

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    How to copy word table from one word document to another word document using excel vba

    Hi,

    I am trying to write an excel vba macro that takes data from several excel and word files and put the data into a word document. In this post i am trying to figure out how to copy a word table (in this case the action item table) from a word document called word_template_1 and paste it into a nother word document called word_template_2 under the Action Section.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,134

    Re: How to copy word table from one word document to another word document using excel vba

    Hi there;

    If all the files (Excel and Word files) are in the same folder, you can try the following Excel VBA code;

    Please Login or Register  to view this content.
    Last edited by Haluk; 10-08-2021 at 01:40 AM.

  3. #3
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,134

    Re: How to copy word table from one word document to another word document using excel vba

    I misread the question and wrong table was inserted into the second word document. It is solved with the revised code given in my previous post.

  4. #4
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,134

    Re: How to copy word table from one word document to another word document using excel vba

    @welchs101, thx for the rep. I hope, your problem is solved...

    .

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: How to copy word table from one word document to another word document using excel vba

    Hi,

    I finally got around to reviewing in more detail the code you gave me. THanks again.

    FYI: It does work but the code gets hung up if one of the word files is already open it shows the dialog box i am enclosing as a jpeg below.
    Actually, it does not show up...the dialog box.......the program just sits there you have to press alt-tab to see it. then you have ot press
    ok for the program to run.

    i did have one question.
    What are the contants you assigned wdgotoline and wdgotonext and wdsavechanges -1 what do these mean?
    why did you pick these integer values?

  6. #6
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,134

    Re: How to copy word table from one word document to another word document using excel vba

    Quote Originally Posted by welchs101 View Post
    .....
    ...
    i did have one question.
    What are the contants you assigned wdgotoline and wdgotonext and wdsavechanges -1 what do these mean?
    why did you pick these integer values?

    When the Word Application is created by "Late Binding" using the "CreateObject" method, you can not use the enumerated constants with their names, you have to use their values.

    In order to find their values, I use the "Object Browser" in MS Word.

    .
    Attached Images Attached Images

+ 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. Copy multiple word documents into one new word document
    By mattmar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2020, 01:36 PM
  2. Replies: 4
    Last Post: 07-27-2020, 10:57 AM
  3. Extract Word header table data to excel (closed word document)
    By Yakov on Excel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2017, 02:12 PM
  4. [SOLVED] VBA in Word, how to copy cells from a table into another word document that contentcontrol
    By reesjordan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-16-2015, 04:39 AM
  5. Add text to Existing Word Document if it Doesn't exist create Word Document
    By unstable81 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-10-2013, 12:15 AM
  6. [SOLVED] VBA word (2003) codes to check if a table fits in a single page of the word document
    By samkumar in forum Word Programming / VBA / Macros
    Replies: 7
    Last Post: 08-27-2012, 09:35 AM
  7. Replies: 0
    Last Post: 06-15-2011, 02:22 PM

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