Results 1 to 5 of 5
  1. #1
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Merging to bookmarks and forms (Word 2003)

    I have a number of automated merges initiated in Access that use Word bookmarks and automation rather than conventional merges.

    For one of these, a 'higher authority' has decreed that the template will now be a protected form. Each of the form fields has a bookmark name. I thought it might work if I just set the name of the bookmark of each field to the ones that used by the code. But this produced an error, that the bookmark was in the protected area of the document. It worked OK if I removed protection from the form.

    Instead I had to place a new bookmark within each form field, and use these for the merge. Then it worked OK when the form was protected.

    I am just wondering if anyone else has experience with merging to bookmarks in protected forms, and has any other suggestions on this problem.
    Regards
    John



  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Merging to bookmarks and forms (Word 2003)

    You can use code like this in a protected form:

    ActiveDocument.FormFields("Test").Result = "Some Text"

    where Test is the bookmark name of the formfield.

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Merging to bookmarks and forms (Word 2003)

    Thanks. That is exactly what I needed.

    This will also allow me to go back to the people who produce the form, and give them a specification that will allow new versions of the form to work with the merge without having to be modified. I hope!
    Regards
    John



  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Merging to bookmarks and forms (Word 2003)

    I now have a further complication with this. There is a section in the middle of the document where a variable number of rows of data have to be entered, and for each row there are 5 bits of data. The "official form" does not really cater for this. It provides for just 3 rows (which is usually enough but not always) with 5 form fields on each row.

    Instead I want to put this data into a table in an unprotected section of the document, and use a loop to put in as many records as needed.
    So I put a bookmark in the first cell of the table then move through the table using

    wrd.Selection.MoveRight Unit:=wdCell at each step and
    wrd.Selection.TypeText Text:=strsomething to put in data.

    But once I protect the document it complains about the MoveRight line (Error 4605) and says the Method is not available because it is a Protected document.
    It will happily let me tab through the table and type into the cells, but not put data in automatically.

    I am pretty sure I have not made an error in protecting the document. How can I get around this?
    Regards
    John



  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Merging to bookmarks and forms (Word 2003)

    You can unprotect the document at the beginning of the macro:

    wrd.ActiveDocument.Unprotect Password:="secret"

    and re-protect it at the end:

    wrd.ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="secret"

    The NoReset:=True part ensures that already filled in form fields will not be cleared.

    (You can omit the Password:="..." part if you haven't set a password)

Posting Permissions

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