Re-protecting a Word Form with VBScript
I have the following code which unprotects and updates a Word template. My problem is that I cannot figure out how to re-protect the form.
Code below:
<script language = "vbscript">
On Error Resume Next
'attempt to get an existing running copy of Word
Set objWord = GetObject(, "Word.Application")
'if error occurred, then couldn't find Word, create new instance
If Err Then
Err.Clear
Set objWord = CreateObject("Word.Application")
End If
objWord.Visible = True
'open template as a new document
Set objDoc = objWord.Documents.Add("H:\Forms\ProtectedForm.dot" )
objDoc.Unprotect
Set objRange = objDoc.Bookmarks("EENumber").Range
objRange.Text = "123456"
Set objRange = objDoc.Bookmarks("EEName").Range
objRange.Text = "Lane, Lois"
'Re-protect document
'I've tried the following 2 methods without success
'objDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
'objDoc.Protect(wdAllowOnlyFormFields,True)
</script>
Any help would be appreciated.
|