Results 1 to 12 of 12
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney Australia, New South Wales, Australia
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unlock Doc created by Form (VBA Word 2000)

    Hi

    I have created some Templates / Forms for use by people who write letters that require some standard wording etc.
    When they use these I have a macro that creates a doc name and selects where the doc is saved.
    That all works Fine

    I changes to the letter are required after it has been saved, the user needs to unlock the document via the Forms tools menu.

    Is there a way I can unlock the document in my Save Macro such that the saved version is unlocked ?

    Thanks for any Help

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Unlock Doc created by Form (VBA Word 2000)

    Do you have a password on the file? If not then the following one liner should suffice.

    ActiveDocument.Unprotect
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney Australia, New South Wales, Australia
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unlock Doc created by Form (VBA Word 2000)

    Hi Andrew

    Thanks for the suggestion but I have tried that and it produces an error as the document is not protected, rather it is locked via template used to produce it as the Template/Form has been locked in the Forms toolbar. Locking the Template / Form in that way allows the user to TAB to the entry fields.

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

    Re: Unlock Doc created by Form (VBA Word 2000)

    ActiveDocument.Unprotect has the same effect as unlocking the document using the Forms toolbar, or selecting Tools | Unprotect document. If you have protected with a password, you should provide that:

    ActiveDocument.Unprotect "topsecret"

  5. #5
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney Australia, New South Wales, Australia
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unlock Doc created by Form (VBA Word 2000)

    Hi Hans

    Thanks for the idea hans

    I have not used a password.
    ActiveDocument.unprotect
    Produces an error as the ActiveDocument is the document produced by using the template/form not the template/form itself.

    Any other ideas would be appreciated.

  6. #6
    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: Unlock Doc created by Form (VBA Word 2000)

    What is your code to save the newly created document? Perhaps you can use the same object:

    <code>myNewDoc.SaveAs ...
    myNewDoc.Unprotect</code>

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

    Re: Unlock Doc created by Form (VBA Word 2000)

    If a template is protected for forms (and it is, if I understand you correctly), a document created from the template will also be protected for forms, unless you have code to unprotect it. So I don't understand the situation.

  8. #8
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney Australia, New South Wales, Australia
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unlock Doc created by Form (VBA Word 2000)

    Hi Hans

    Yes that is exactly my situation, I need the code to unprotect the new document created from the locked form/template.

    I assume that the new document becomes the ActiveDocument but
    ActiveDocument.unprotect in the Save Macro
    gives an error that the document is not protected, it is however locked for forms.

    So how do I unlock (Forms) in the new document in a save macro so that the user can then go into his or her saved document and edit anything they like (i.e. doc not locked to alow field entries only) ?

    Thanks for any input

  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: Unlock Doc created by Form (VBA Word 2000)

    You could test if the doc is protected, and if so, unprotect it:
    <font face="Georgia">If ActiveDocument.ProtectionType <> wdNoProtection Then
    ActiveDocument.Unprotect 'give password if applicable
    End If</font face=georgia>

    Another thought: if you have multiple documents open, then maybe ActiveDocument is not the document that you expect it to be and is the code therefore acting on the wrong document. It wouldn't be the first time that Word loses track of the right document.

  10. #10
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney Australia, New South Wales, Australia
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unlock Doc created by Form (VBA Word 2000)

    Hi Jan

    Thanks for the suggestion but only one document is open, i.e. the one created by, for example, double clicking the Template / Form.

    There appears to be the feeling that I have a Protected Document.
    Maybe I should explain further.
    I don't. I have a protected document, I have a locked document
    Locked documents are produced by clicking on the padlock in the Forms Toolbar, a protected document is produced by clicking Tools - then selecting Protect Document.
    These do not appear to me to be the same thing.
    Maybe I have got it wrong, if I have I would greatly appreciate a more detailed explanation of how these are connected.

    Thanks for any Help

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

    Re: Unlock Doc created by Form (VBA Word 2000)

    The Tools | Protect Document dialog offers three protection options:
    - Tracked changes
    - Comments
    - Forms
    Selecting the third option is identical to locking the document using the "Lock" button on the Forms toolbar.

  12. #12
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney Australia, New South Wales, Australia
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unlock Doc created by Form (VBA Word 2000)

    Thanks Hans

    I did not know that the Protect Had that option

    I will try to record a macro using Tools - Protect and see what I can do that way.

Posting Permissions

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