dcsimg
Results 1 to 2 of 2

Thread: Scan and save a word document to vba and regenerate later

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2019
    Posts
    1

    Scan and save a word document to vba and regenerate later

    Hi,

    I'm automating word report from excel. The report includes many tables and formats. So I start with a template word with empty tables, and bookmarks and content controls. I use excel to open this word file, then fill or change texts and tables located by these bookmarks and content controls.

    I want to ask if there is a way to "scan" this word template into excel VBA, so I can regenerate this word template by VBA.
    In other words, convert a word.docx into vba code, which can regenerate the word.docx based on vba code.

    So I don't have to use two files(one excel and one word) to generate report. I could only use one excel.

    Thank you for help,

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,497

    Re: Scan and save a word document to vba and regenerate later

    it is quite be possible to create a word document just from code, but the amount of code to create a document of the suggested complexity may not be worth the effort, though it only has to be done once

    you would need to add every object (tables, bookmarks, content controls etc, to the document, position and size them correctly, set fonts and other properties

    excel can in itself present reasonably presented documents, but i can not know if that could be suitable for you
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width