Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    May 2009
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Word 2003

    A dialog box collects information when the template opens. When OK button clicked, the variables fill the document. The revised template I'm working on works the same way but also needs to open a second document and fill it with the same variables at run time. When all is done, two documents will be open containing the same variable information that was collected in the opening dialog box (each document is for a different insurance product).

    Is there a best method to make this happen? The number of variables used will be less than 10 so very small.

    If you could please provide a small amount of code to get me started, it would be appreciated as I'm not an advanced programmer but I do borrow a lot of ideas for templates and have gotten many of them in this forum. Otherwise, just a good description of what needs to happen will still be very helpful.

    Thank you!!
    Charlie
    charlie6067

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Should the code (1) open an existing document, or (2) create a new document from a template (if so, which template), or (3) create a blank new document?

  3. #3
    Star Lounger
    Join Date
    May 2009
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply. The second template will already be made and saved in a folder. It will have alot of the same text and bookmarks as in the first document. At run time, the first document will call the second to open and receive the same variables as the first document.

    The first document is not just one document but a series of individual documents that are called and assembled depending upon what product choices the user selects in the dialog box. The final document could be over 100 pages if the user selected all of the products.

    The second document with different bookmarks will be called at run time and filled with the same variables. I'm not sure how to use the named variables from the first document to open and fill the bookmarks of the second one.

    I hope that's clear but please let me know if more detail is needed.

    Thank you for your help!

    Charlie
    charlie6067

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Here is a rough idea of the code you'll need.

    Code:
    Dim doc2 As Document
    Dim strFilename2 As String
    Dim rng2 As Range
    Dim strText As String
    ' Change the following string as needed
    strFilename2 = "C:\Word\OtherDoc.doc"
    ' If you want to create a new document based on strFilename2,
    ' change Open to Add in the line below
    Set doc2 = Documents.Open(strFilename2)
    strText = ...
    Set rng2 = doc2.Bookmarks("MyBookmark").Range
    rng2.Text = strText
    doc2.Bookmarks.Add "MyBookmark", rng2
    ...

  5. #5
    Star Lounger
    Join Date
    May 2009
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, Hans! I will try it.

    Charlie
    charlie6067

Posting Permissions

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