Consulting

Results 1 to 3 of 3

Thread: copy multiple ranges from Excel to tables in Word with VBA

  1. #1
    VBAX Newbie
    Joined
    Jul 2017
    Location
    Dordrecht
    Posts
    5
    Location

    copy multiple ranges from Excel to tables in Word with VBA

    Hi everybody, I have been trying for sometime now, to copy multiple ranges from Excel to tables in Word with VBA but still without succes...

    I have a Excel document that i use to generate text to use as test documents, to every item i want to test i do a automated search with VBA for the template(in my excel workbook) that i use and add it's specifications.

    That goes perfect, and i have been using it for a long time.

    I would use the text/documents in Word with a specific layout, every time i have to copy everything from Excel to Word and print it...
    Can any of you help me to do this with VBA?

    Here is the file i use:
    Test_Workbook.xls

    ...and here is what every range of text between the words "START" and "END" should look like in Word:
    Schermafbeelding 2017-07-26 om 09.10.24.jpg
    Last edited by nito; 07-26-2017 at 02:00 AM.

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    I got a warning when I opened your file about enabling it potentially harming my computer, so that's as far as I went.

    If you're always using the same Excel range for the linking, you could simply use copy/paste with the 'paste link' option in Word and a suitable paste format to automatically replicate the data. No macros needed. If you do this using a Word template, then break the links immediately a new document is created (e.g. via Ctrl-A, Ctrl-Shift-F9), each new document will retain a permanent copy of the data at that time.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Newbie
    Joined
    Jul 2017
    Location
    Dordrecht
    Posts
    5
    Location
    Quote Originally Posted by macropod View Post
    I got a warning when I opened your file about enabling it potentially harming my computer, so that's as far as I went.

    If you're always using the same Excel range for the linking, you could simply use copy/paste with the 'paste link' option in Word and a suitable paste format to automatically replicate the data. No macros needed. If you do this using a Word template, then break the links immediately a new document is created (e.g. via Ctrl-A, Ctrl-Shift-F9), each new document will retain a permanent copy of the data at that time.
    Sorry, I didn't see the warning, but it's probably because i edited the file yesterday on my Mac. But here is the complete file:
    Formulieren_Tool2_R0.xls

    I use the Sheet "Tags" to fill wat tags i want to convert into testing documents, every tag has it's document "typical", and that i define in the Column "Typical".
    When i run the VBA code it inserts the tagnames into the typicals(templates in sheet UDT) and copys them to sheet "Testen".
    What i need is the Templates/typicals/tables or what you want to call it to be exported to a word template that i have created with the company layout so i can print them and use as test documents when testing them with the client.

    Hope i explained enough, because my english is not always as good as i would like...

Posting Permissions

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