+ Reply to Thread
Results 1 to 10 of 10

Looping through an Excel list to generate a dynamic Word document

Hybrid View

  1. #1
    Registered User
    Join Date
    03-22-2011
    Location
    France
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Looping through an Excel list to generate a dynamic Word document

    I tried to used mailmerge actually, but I was blocked because the generated document was not "dynamic" and the mailmerge function creates me 1 Word document for each line in the Excel document.
    The fields were static, and that was not what I was looking for.

    Here's the structure of my Excel file :
    Phase ----- Phase Description ----- Phase Beginning date ----- Phase Ending date ----- Phase ressources


    In addition to that, I would need to have a global field for the following fields :
    Document Reference
    Document Date
    Read by (name of verificator)
    Writed by (name of writer)

    And this would create a Word composed of a title (Document Reference) a first page containing my document information (date, reader, writer, brief introduction), then a summary with the content of the document, which would be composed of :
    I. Phase 1
    --- Description Phase 1
    --- Date Phase 1
    --- Ressources Phase 1

    II. Phase 2
    --- Description Phase 2
    --- Date Phase 2
    --- Ressources Phase 2

    ...

    And so on, depending on the number of line of the Excel document.

    Did I made my point clear ? It's not easy to explain in english, as I'm french :P

    Thanks anyway !

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Looping through an Excel list to generate a dynamic Word document

    In the attachment a Word document with a macro.

    The only thing you have to change in the macro is the fullname of the Excel-file.
    Then you can 'play' the macro and see the result in your document.
    You can switch the fieldview using Alt-F9.

    Awaiting your feedback.
    Attached Files Attached Files



  3. #3
    Registered User
    Join Date
    03-22-2011
    Location
    France
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Looping through an Excel list to generate a dynamic Word document

    You're macro is a very good beggining to help me.
    I still have one more question about this :
    - How would I apply a "style" to the content of a cell ? (like in your macro, apply title_1 style to the sq(j,1) for instance)

    Thank you very much for your fast answer :-D

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Looping through an Excel list to generate a dynamic Word document

    In the example file I put the whole content of sheet1 into 1 Word-field.
    Since I have no idea how you want to format the distinct elements I can't give a simple solution.
    It would be nice to post an example of the Excel sheet and of the layout in your Word-document.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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