Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to Unprotect Form (XP)

    I'm trying to create a macro to unprotect a form. Here's the scenario.
    I've created an AutoText entry that is a protected form. When adding the information into the last field of the AutoText entry, I would like to run a macro on exit that would unprotect the form so the user can continue typing in the document.
    Any ideas?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Macro to Unprotect Form (XP)

    The macro is simple: ActiveDocument.Unprotect

    But if it is the last form field in the document, is there any easy way for the user to trigger the On Exit macro?

    Actually, I don't know whether all of the properties of that form fields will survive the save-to-AutoText and insertion-into-document. Sounds like a novel approach!

  3. #3
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Unprotect Form (XP)

    You could split the document into 2 sections, the one with the FormFileds and the other for the user to type whatever (s)he wants. Then make the first section ProtectedFor Forms and the second not, then activate documentprotection. After the user has filled the last Formfield of Section(1) and exits it with the Tab key, the cursor is automatically placed at the beginning of Section(2) and the user can type away.

    Added
    'This method has one big disadvantage: a lot of Word funtionality is not available in a protected document. But there is an alternative, where protection is toggled depending on the position of the cursor. See HansV's <post:=342,898>post 342,898</post:> for a step by step elaboration of my original idea.

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Unprotect Form (XP)

    This needs to be autotext or macro and inserted at the end of a document. It's the Notary closing for legal documents.

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Unprotect Form (XP)

    I need to try the opposite. I created a autotext with notary signature content in a protected form. Then, I created a macro to run that autotext. I need the protect the autotext before I begin typing. I was thinking that Protect is the opposite of unprotect, but guess I'm wrong!

    Application.DisplayAutoCompleteTips = True
    NormalTemplate.AutoTextEntries("notarycorp").Inser t Where:=Selection.Range _
    , RichText:=True
    ActiveDocument.Protect - I GET A COMPILE ERROR HERE

  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macro to Unprotect Form (XP)

    I'm not sure what error you are getting, but you probably want the syntax
    <code>ActiveDocument.Protect Type:=wdAllowOnlyFormFields</code>

    StuartR

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Macro to Unprotect Form (XP)

    For best results, create a section break before inserting your AutoText and protect only that section. Otherwise, users will have to unprotect to change anything else. Actually, they will have to unprotect to change paper trays, so this might not be the most convenient approach.

    As an alternative, could you insert the unchangeable parts as an image? Oh, maybe not if the text fields are of variable length. Hmmm...

  8. #8
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Unprotect Form (XP)

    It's still not clear to me what you're trying to accomplish. I'm not familiar with Notary closing, so that doesnt mean anything to me. Can you attach example documents with and without the AutoText inserted?

  9. #9
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to Unprotect Form (XP)

    <hr>Actually, I don't know whether all of the properties of that form fields will survive the save-to-AutoText and insertion-into-document. <hr>
    AutoText entries can contain FormFields and their properties will be preserved when inserted into a document. I use this very often. They can be called by their name after insertion, provided that the names of the FormFields are unique for the whole document. If a name already exists, then either the inserted FormField ends up nameless, or the previously present FormField loses it's name. (It's not clear to me why this behaviour isn't consistent.)

Posting Permissions

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