Checking readonly & password without opening file

E

Eithne R

Hi, I'm trying to check the Read Only and Password protection properties of
a list of Word (and Excel) files by a macro. Is there a VBA method, that I
can use in batch, to check these properties without actually opening the
file itself? If the
file is password protected I obviously cannot open the document in batch to
check the ActiveDocument property.

Check if the document is read only
ActiveDocument.ReadOnly
ActiveDocument.ReadOnlyRecommended

Or a way to find out if document has been password protected:
ActiveDocument.SaveAs .. Password:="pwd"
ActiveDocument.SaveAs .. WritePassword:="pwd"

I tried to use the "Microsoft Scripting Runtime" library FileSystemObject
but it did not give me the file properties I needed. If possible, I would
like to run this check from an Excel macro.

Thanks for your help in advance, E
 
J

Jean-Guy Marcil

Eithne R was telling us:
Eithne R nous racontait que :
Hi, I'm trying to check the Read Only and Password protection
properties of a list of Word (and Excel) files by a macro. Is there
a VBA method, that I can use in batch, to check these properties
without actually opening the file itself? If the
file is password protected I obviously cannot open the document in
batch to check the ActiveDocument property.

Check if the document is read only
ActiveDocument.ReadOnly
ActiveDocument.ReadOnlyRecommended

Or a way to find out if document has been password protected:
ActiveDocument.SaveAs .. Password:="pwd"
ActiveDocument.SaveAs .. WritePassword:="pwd"

I tried to use the "Microsoft Scripting Runtime" library
FileSystemObject but it did not give me the file properties I needed.
If possible, I would like to run this check from an Excel macro.

Thanks for your help in advance, E

See
http://word.mvps.org/FAQs/MacrosVBA/CheckIfPWProtectB4Open.htm
for an example.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top