Share via

Fields clear upon document unlock

Anonymous
2017-06-16T05:25:12+00:00

I have a Word document that I need to unlock after all fields are filled.  I've written a macro to do this that runs on exit at the last field HOWEVER, when the document unlocks, all the fields clear and I don't want that!  My macro is:

With ActiveDocument

        .Unprotect

End With

***Post moved by the moderator to the appropriate forum category.***

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

9 answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2017-06-19T07:37:14+00:00

    Hi Marilyn,

    It was not the removal of the protection that was causing the formfields to be reset, but the command to select the dropdown1 bookmark after the protection had been removed.

    I do not know why that was causing the formfields to be reset and I noted that they were also reset if that dropdown1 formfield was selected BEFORE the protection was removed.

    I'll be interested to see if Jay comes up with any idea on why that might be happening.

    I have sent you back a modified document that I believe should do everything that you require without the issue occurring.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2017-06-19T01:16:13+00:00

    Document e-mailed.

    Thankyou!

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Jay Freedman 207.7K Reputation points Volunteer Moderator
    2017-06-17T21:09:47+00:00

    If the fields are cleared as soon as the Unprotect statement runs, that would be something I've never seen in 20 years of Word macro writing.

    However, if you're then reprotecting the document with a statement like

       ActiveDocument.Protect Type:=wdAllowOnlyFormFields

    then that definitely will clear all the formfields. To prevent that, you must include the optional parameter

       ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  4. Jay Freedman 207.7K Reputation points Volunteer Moderator
    2017-06-19T00:10:07+00:00

    If you send me a copy of the document (after removing any confidential information), I'll try to find out what's causing the fields to clear. You can attach it to an email to either of the addresses listed at https://jay-freedman.info/contact/contact.htm.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2017-06-18T23:53:50+00:00

    Trust me, the fields are clearing as soon as the unprotect statement runs!

    Word doesn't recognise "ActiveDocument.Unprotect Type:=wdAllowOnlyFormFields, NoReset:=True" and the fields clear if I write "ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True" followed by the unprotect statement.

    I'm supposed to leave the document unprotected, with the fields filled in (Management's decision).

    Was this answer helpful?

    0 comments No comments