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

Select Editting restriction in word using vbscript

Status
Not open for further replies.

vkumar2

Programmer
Sep 17, 2009
2
GB
Hi ,

This is vinod , i was just trying to write a vbscript to protect a word document and as well as select Editting restrictions as filling in forms, but i could only protect the form but not able to select editting restrcitions, I am just breaking my head to do this ,can you please help me and solution for this will appreciated.

Mycode :-
Dim dataDocLocation, msWord, msWordDoc, oTransports
Dim oError, oErrorD
Dim oDescription
dataDocLocation = "E:\PPR CR Sign off form4.doc"
Set msWord = CreateObject("Word.Application")
Set msWordDoc = msWord.Documents.Open(dataDocLocation)
Set msWordDoc = msWord.ActiveDocument
msWordDoc.Unprotect "prodapp"
msWordDoc.Tables(3).Cell(2,1).Range.Text= "descrtiption"
msWordDoc.Tables(6).Cell(3,3).Range.Text = "123 123123" msWordDoc.Protect wdNoProtection,False,"prodapp",False,True
msWord.Application.Visible = True
 
but not able to select editting restrcitions"

Explain this please. What restrictions?

"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
BTW, I sure hope that:

msWordDoc.Tables(6).Cell(3,3).Range.Text = "123 123123" msWordDoc.Protect wdNoProtection,False,"prodapp",False,True

is not actually on one line. I am not sure that is correct syntax either.

.Protect has three parameters: Type, NoReset, Password

That looks like you are using five.

Further,
Code:
.Protect wdNoProtection
does just that. No protection. Thus...no restrictions imposed.

"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
Hi,

Here is the syntax for .protect which i had used.

odoc.Protect(Type, NoReset, Password, UseIRM, EnforceStyleLock)

What iam trying is I have a form in word , where i have to restric users to only fill in the form. so there is a option for it , Tools--> protect Document-- >Formatting Restrictions --> EdittingRestrictions -- > select "Filling in forms" Option from the drop down and click yes to type a password.

so please help me to achieve this in vbscript

Thanks & regards
Vinod.
 
Ah, you are using 2007. It really helps if you state what version you are using.

"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
BTW: the second line here is redundant, as it is essentially the same thing as the first line.
Code:
Set msWordDoc = msWord.Documents.Open(dataDocLocation)
Set msWordDoc = msWord.ActiveDocument

The first line sets msWordDoc as the ActiveDocument, by opening the file. When Word opens a file, THAT becomes ActiveDocument.


"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top