View Single Post
 
Old 07-15-2011, 04:59 AM
PosseJohn PosseJohn is offline Windows XP Office 2007
Novice
 
Join Date: Jul 2011
Posts: 20
PosseJohn is on a distinguished road
Default Preventing Form Fields to Reset

Greetings,

I have a WORD document that contains Form Fields for the user to enter information. This document is repeatedly used from one shift to another, it contains information for shift turnover.

I want to FORCE the user to enable macros so that when the user closes the document, it automatically creates a 'archive' copy of the file, with the current date/time in the file name, saved to a different folder, for retrieval if something got fouled up.

I attempted to protect the document from any changes upon closing, and then upon opening, I would unprotect the document, then re-protect it allowing 'Filling in forms'.

When I do this, all the fields reset to empty.

I don't want the user to have to retype everything, only edit what might have changed in the last shift, then save it.

Here is my code:

Code:
 
Private Sub Document_Close()
        With ThisDocument
            .Unprotect Password:="pw"
            .Protect Password:="pw", _
                    NoReset:=False, _
                    Type:=wdAllowOnlyReading, _
                    UseIRM:=False, _
                    EnforceStyleLock:=False
        End With
End Sub
Code:
 
Private Sub Document_Open()
        With ThisDocument
            .Unprotect Password:="pw"
            .Protect Password:="pw", _
                    NoReset:=False, _
                    Type:=wdAllowOnlyFormFields, _
                    UseIRM:=False, _
                    EnforceStyleLock:=False
        End With
End Sub
Reply With Quote