Results 1 to 12 of 12
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Forms and protection (2000)

    I've got form fields on the front page of a template and want to use a macro button to then update all the fields in the document with the bookmarked text.
    However, the macro halts because the document (first section) is protected. How can I get round this catch 22? Thanks, Andy.

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

    Re: Forms and protection (2000)

    If you tick the "Calculate on exit" check box in the properties of the relevant form fields, references to these form fields will be updated automatically, without needing code.

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms and protection (2000)

    Thank you - that works great.
    I'm trying to get an IF field working that refers to one of the form fields. I'm using a Checkbox and need to know the correct 'syntax'. I'm using { IF bkTick=0 "" "Alternative text" } but it's not working. What is the correct syntax? Thanks, Andy.

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

    Re: Forms and protection (2000)

    Unfortunately, you cannot refer to the value of a form checkbox in an IF field. You'll need to write a macro and set it as the On Exit macro of the checkbox. You can use code like this in the macro:

    If ActiveDocument.FormFields("bkTick").CheckBox.Value = False Then
    ...
    Else
    ...
    End If

  5. #5
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms and protection (2000)

    That's great. Thanks.

  6. #6
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms and protection (2000)

    OOPS! I now need to copy bookmark text to another document - but I still can't do this while the main document is protected?! How can I unprotect a document using VBA to read the bookmark text? Thanks, Andy.

  7. #7
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms and protection (2000)

    Actually.. I've managed to unprotect it by how can I 'refer to' the FORMFIELDS 'text'? For example, Bookmarks("bkSome").Range.Text doesn't retrieve the text entered in the Form Field? Sorry about all these questions.. Andy.

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

    Re: Forms and protection (2000)

    Use the Result property of the FormField:

    ActiveDocument.FormFields("bkSome").Result

    Note that this uses the FormFields collection, not the Bookmarks collection. It can be used whether the document is protected for forms or not.

  9. #9
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Forms and protection (2000)

    Hi Andrew,

    Here's a simple workaround:
    . In your protected document, create a SET field coded along the lines of '{SET BkMrk {REF Text1}}', where BkMrk is a bookmark name you can use in your target document and 'Text1' is the name of the bookmark set by your formfield.
    . In your target document, code your INCLUDETEXT field to refer to the new bookmark name in your source document.

    No vba required.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  10. #10
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms and protection (2000)

    I'm quite excited by your suggestion.. but can't quite follow it. What does the SET field do exactly, and what syntax does INCLUDETEXT use to refer to a Bookmark in another document?

    Thanks (yourself and Hans), Andy.

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

    Re: Forms and protection (2000)

    The SET field creates an invisible bookmark named BkMrk (or whatever name you specify) and sets the value of this bookmark to the value of the formfield.

    To create the INCLUDETEXT field in the other document, select Insert | Field...
    Select INCLUDETEXT, then click the Field Codes button below the list of fields.
    Make the code look like this:

    INCLUDETEXT "C:WordMyDoc.doc" BkMrk

    substituting the correct path and field name of the document containing the formfields, and also specifying the correct name of the bookmark you created in the SET field.
    Finally click OK.

  12. #12
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Forms and protection (2000)

    Hi Andy,

    The SET field simply creates a bookmark. To create the one in my previous post, you'd press Ctrl-F9 twice, to create a pair of nested fields, then fill in the details.

    The INCLUDETEXT field is what Word uses to link material in one document to another. It's what Word Word creates behind the scenes when you select something in your source document and paste it into the target document using Edit|Paste Special|Link. If you then select the pasted material in the target document and press Shift-F9, you'll see something like:
    {INCLUDETEXT "C:My DocumentsSource.doc" "OLE_LINK1"}

    Your can create your own such field via Insert|Field, or by pressing Ctrl-F9, and filling in the details. Taking the example from my previous post, you'd end up with something like:
    {INCLUDETEXT "C:My DocumentsSource.doc" "BkMrk"}
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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