Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / April 2006

Tip: Looking for answers? Try searching our database.

Editing Restriction

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kausar - 10 Apr 2006 13:21 GMT
Hello All,

        I have a Word Template project created using VSTO 2005.  I am
trying to restrict the editing of the document except from the actionpane
form. I am doing it from the VS 2005 IDE, the button which says "Yes, Start
Enforcing Protection" never gets enabled. Then I came to know from this link
http://whidbey.msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstc
ore/html/a25472ad-03f0-4804-9d19-e5ff71340d49.asp

that we can't set the "Yes, Start Enforcing Protection"  in the design mode.
coz in the run mode the setting "Editing Restriction" can only be apply to
that instance of the document. Then how do i do this to the template?

Thanks in advance,
Best Regards
Kausar
Richard Hogan - 11 Apr 2006 15:44 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.