Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unprotect then protect doc looses form information

Status
Not open for further replies.

harky

Technical User
Oct 29, 2001
39
GB
Hi

I need to run a macro on protected documents which firstly unprotects them (they are not password protected) then runs a number of search and replaces, then protects the forms again, saves , then exits.

The problem is the forms are filled in and when I choose to protect again all the form information is cleared - is there anyway of retaining the form information?

Thanks in advance
Harky
 
I'm assuming you're using Word.

I've noticed this problem before but don't know a built in way around it. The only way I know is to store all of the formfield results in an array before you unprotect the document and then copy the array values back to the formfield result after you've protected the document.
 
Use the NoReset parameter ...
Code:
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=etc.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top