• Unlock Doc created by Form (VBA Word 2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Unlock Doc created by Form (VBA Word 2000)

    Author
    Topic
    #438796

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1047126

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

      ActiveDocument.Unprotect

      • #1047600

        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.

        • #1047607

          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”

          • #1047610

            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.

            • #1047612

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

              myNewDoc.SaveAs ...
              myNewDoc.Unprotect

            • #1047615

              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.

            • #1047632

              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

            • #1047637

              You could test if the doc is protected, and if so, unprotect it:
              If ActiveDocument.ProtectionType wdNoProtection Then
              ActiveDocument.Unprotect ‘give password if applicable
              End If

              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.

            • #1047850

              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

            • #1047854

              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.

            • #1047873

              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.

    Viewing 0 reply threads
    Reply To: Unlock Doc created by Form (VBA Word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: