Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    May 2014
    Thanked 0 Times in 0 Posts

    Forms Being Reset When Document Unprotected/Protected in Macro

    I have a document that has form fields the user fills in. The document has editing restrictions to allow the user to only fill in the form fields. When I use a macro to Unprotect and then Protect the document, the data the user has filled in in the form fields gets erased and the form fields revert back to the placeholder, erasing any data previously added.

    For Example:

    City: { FORMTEXT } State: { FORMTEXT } Zip Code: { FORMTEXT }

    When the document is protected, the user can tab from form field to form field and fill in the data. I need to Unprotect the document to work with some of the data, but when I do so using a Macro, the data previously entered is erased. This doesn't happen if I just Protect/Unprotect/Protect the document from within Word. Any ideas why this would be happening when using a macro? Any solutions? Thanks for your help!

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    May 2002
    Canberra, Australian Capital Territory, Australia
    Thanked 179 Times in 165 Posts
    You need to use the 'NoReset' parameter when re-protecting. For example:
    Sub UpdateForm()
    Dim Pwd As String
    Pwd = ""
    With ActiveDocument
      .Unprotect Password:=Pwd
      'Do unprotected processing here
      .Protect Type:=wdAllowOnlyFormfields, NoReset:=True, Password:=Pwd
    End With
    End Sub

    Paul Edstein
    [MS MVP - Word]

  4. The Following 2 Users Say Thank You to macropod For This Useful Post:

    RandyMc (2014-05-18),sffrog (2014-05-30)

  5. #3
    New Lounger
    Join Date
    May 2014
    Thanked 0 Times in 0 Posts
    Thank you so much!!

Tags for this Thread

Posting Permissions

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