Protection Type for Word template
Posted on 2008-10-08
I am using word 2003.
In my word document template file CustomerRequest.dot I have 15- 20 bookmark fields form fields.
To fill in these fields I put on template several command buttons that I use to open several UserForms.
Those UserForms I am using for gathering and validation data from a customer.
When a user opens my template it is protected. I am using Tools Protect Document options to protect document it means no any changes on document form fields -bookmarks just through user forms.
When a user enters data in a UserForm I do validation and save values from text boxes on the UserForm to template form fields bookmarks.
I dont allow users to change data in template form fields just to read it. Only time when template is unprotected is time when data are saved- moved from User form to template bookmarks-form fields.
On the UserForm (frmCustomerInfo) I have save button in Click event I have this code.
Dim strCompliantDate As String
Dim strCustomerName As String
Dim strReferenceNum As String
If Me.txtCompliantDate = "" Then
MsgBox "Please enter compliance date"
If Me.txtCustomerName = "" Then
MsgBox "Please Enter Customer Name"
strCompliantDate = Me.txtCompliantDate
strCustomerName = Me.txtCustomerName
strReferenceNum = Me.txtReferenceNum
ActiveDocument.FormFields("fldCompliantDate").Result = strCompliantDate
ActiveDocument.FormFields("fldCustomerName").Result = strCustomerName
ActiveDocument.FormFields("fldReferenceNum").Result = strReferenceNum
Problem is that in word 2003 this is ok but in word 2002 I dont have Protect Type option wdAllowOnlyReading- .
I got VB error variable not defined on the line:
In word 2002 I have those protect type : wdAllowOnlyComment, wdAllowOnlyFormField, wdAllowOnlyRevisions, WdNoProtection.
I assume that word 2000 and 97 are the same. What to do to have this template work in all word versions?
I dont want to have wdAllowOnlyFormField as I dont want user to change data in my template bookmark fields I want to force them to go through UserForm edit, validation and save procedure.