Sign in to follow this  
Followers 0
anilshekhar

How do I get the MS Word protection information using AutoIT?

9 posts in this topic

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
 

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 protection

Edit: See here for more info - http://msdn.microsoft.com/en-us/library/office/jj230379(v=office.15).aspx

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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:

AllowOnlyComments

AllowOnlyFormFields

AllowOnlyReading

AllowOnlyRevisions

NoProtection

So, 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 by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thanks for your reply again ... I am trying to determine the level of protection ... 

Share this post


Link to post
Share on other sites

#7 ·  Posted (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.
 
 
I wonder why the return value is -1 for a doc without any protection ... Is this expected?
Edited by anilshekhar

Share this post


Link to post
Share on other sites

Wow, Amazing help and support ... Thanks so much SmOke_N.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0