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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Protect a Word form using VB Script 1

Status
Not open for further replies.

bill07

Technical User
Mar 6, 2007
6
0
0
GB
Hi All

I have a HTA which when a button is clicked, will open a microsoft word document.

The microsoft word document contains forms (ie check boxes, textbox, listbox, etc)

I can get the document to open in MS Word using vbscript but I would like to know how would I protect the document so that users can use the form to make some selection.

The code that i have to open the ms word document is

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add("filepath")

where filepath is the path of the document.

In VBA, I can protect the document by using the statement below

If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True


Thank you

Bill
 
something like this ?
If objDoc.ProtectionType = -1 Then
objDoc.Protect 2, True
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you PHV. I have attached your suggestion/solution to the script and this had resulted in the Word from being protected for the user to make a selection.

Thanks again

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top