Hi Kauser
You should be able to protect documents from the word tools menu, I believe
there is a menu option for protect and unprotect documents. Alternatively
you can set it up in the startup section of your code with a line like.
Private Sub ThisDocument_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup
Me.Protect(Word.WdProtectionType.wdAllowOnlyReading)
End Sub
I hope this helps.
Cheers
Richard
> Hello All,
>
[quoted text clipped - 10 lines]
> Best Regards
> Kausar
Kausar - 12 Apr 2006 06:35 GMT
Hello Richard,
I know there is a menu option from were we can set to protect and
unprotect documents. But this will apply to that opened instance of
the word document. My problem is to apply the "Editing Restriction" to all
those document which are opening on the basis of my word template. My
word template have a action pane from where i have given some form fields.
I want the user to make changes in the document opened on the
basis of my word template only through the given form fields. For that i
wrote
object noReset = false;
object password = "test";
object useIRM = false;
object enforceStyleLock = false;
this.Protect(Word.WdProtectionType.wdAllowOnlyFormFields, ref
noReset, ref password, ref useIRM, ref enforceStyleLock);
on ThisDocument_Startup. But When i am filling the form fields and submit
the document action pane. It is giving error
"You are not allowed to edit this region because document protec\tion is in
effect."
I want to let the user to make changes only through form fields.
The user can't write anything on the document.
I want the above things to be done on all those document which the user
opens on the basis of my word template.
Best Regards
Kausar
> Hi Kauser
>
[quoted text clipped - 31 lines]
>> Best Regards
>> Kausar
Kausar - 12 Apr 2006 09:38 GMT
Hello Richard!!
Got success in editing restrictions. I did it this way. I
called the Protect method on the ThisDocument_Startup as you said. On
'Submit' of the 'document action pane', i Unprotect the document. Then after
replacing the field values on the document again I applied the restriction
to the document using Protect method.
Thanks!!! & Regards
Kausar
> Hi Kauser
>
[quoted text clipped - 31 lines]
>> Best Regards
>> Kausar
Richard Hogan - 12 Apr 2006 10:25 GMT
Hi Kauser
I'm glad you got it working, however you should not have to unprotect and
then protect the document if you are just updating the form field values.
You should just be able to use something like
me.FormFields("FormFieldName").Result = "test"
Which will update the form fields without requiring the document to be
unprotected.
Cheers
Richard
> Hello Richard!!
>
[quoted text clipped - 42 lines]
> >> Best Regards
> >> Kausar