anilshekhar Posted December 2, 2014 Share Posted December 2, 2014 I need to access the MS Word document protection information. Open MS Word Click on Developer tab (Other tabs that are also present are File, Home, Insert, Page Layout, References, Mailings, Review and View). Click on Restrict Editing On your right you will see a panel/frame "Restrict Formatting and Editing". How do I access this text? I am able to get to this step but then I am kind of lost on how to move ahead and fetch the data. Example of the text that I am looking to access are ... "Your permissions This document is protected from unintentional editing. You may edit in this region, but all changes will be tracked." "Your permissions This document is protected from unintentional editing. You may only insert comments in this region." "Your permissions This document is protected from unintentional editing. You may only fill in forms in this region." "Your permissions This document is protected from unintentional editing. You may only view this region." Thanks for your help Anil Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 2, 2014 Moderators Share Posted December 2, 2014 (edited) Are you looking to protect a document? Something like this should suffice: #include <Word.au3> $oWord = _Word_Create() $oDoc = _Word_DocOpen($oWord, @DesktopDir & "\Test.doc") Sleep(1000) $oDoc.Protect(1)Sets the doc to read only protectionEdit: See here for more info - http://msdn.microsoft.com/en-us/library/office/jj230379(v=office.15).aspx Edited December 2, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
anilshekhar Posted December 2, 2014 Author Share Posted December 2, 2014 First of all thanks JLogan3o13. I am looking to access the protection level of a MS Word. Like I mentioned earlier, I see there are several levels of protection. From my understanding default out of the box is full access. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 2, 2014 Moderators Share Posted December 2, 2014 (edited) Correct, and as my example shows you can set that protection level. As the link I provided shows, you can set it to one of the following:AllowOnlyCommentsAllowOnlyFormFieldsAllowOnlyReadingAllowOnlyRevisionsNoProtectionSo, my question again is what exactly do you mean by "access" the protection level? Are you looking to set that level, or to determine what the level is? Edited December 2, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
anilshekhar Posted December 2, 2014 Author Share Posted December 2, 2014 Thanks for your reply again ... I am trying to determine the level of protection ... Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 2, 2014 Moderators Share Posted December 2, 2014 You can query the protection type like this: #include <Word.au3> $oWord = _Word_Create() $oDoc = _Word_DocOpen($oWord, @DesktopDir & "\Test.doc") Sleep(1000) ;$oDoc.Protect(1) MsgBox(0, "", $oDoc.ProtectionType) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
anilshekhar Posted December 2, 2014 Author Share Posted December 2, 2014 (edited) Thanks again. Here are the return values I got for various protection types. -1 / "Full access.docx" / wdNoProtection / Do not apply protection to the document. 0 / "Insert comments and tracked changes only.doc" / wdAllowOnlyRevisions / Allow only revisions to be made to existing content. 1 / "Insert comments only.doc" / wdAllowOnlyComments / Allow only comments to be added to the document. 2 / "Fill in form fields only.doc" / wdAllowOnlyFormFields / Allow content to be added to the document only through form fields. 3 / "Read only.doc" / wdAllowOnlyReading / Allow read-only access to the document. http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document.protectiontype.aspx http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.wdprotectiontype.aspx I wonder why the return value is -1 for a doc without any protection ... Is this expected? Edited December 2, 2014 by anilshekhar Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 3, 2014 Moderators Share Posted December 3, 2014 http://msdn.microsoft.com/en-us/library/ff844959(v=office.14).aspx Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
anilshekhar Posted December 3, 2014 Author Share Posted December 3, 2014 Wow, Amazing help and support ... Thanks so much SmOke_N. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now