Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Office document protection

Reply
 
Old 02-08-2009   #1 (permalink)
chris


 
 

Office document protection

I've seen a number of samples to open an Office document (ie. word,
excel, etc.) that is password protected using VBScript. My problem is
a bit different. I'm performing a recursive search on a directory and
its subdirectories for word documents, and then extract information
from those documents. However, some of the word documents, not all,
are password protected. Also, not all of the passwords are the same.
I was thinking that when trying to open the documents to get the
information, I could put the passwords in an array and then loop
through the array until the correct password is entered. However, I
didn't want to have to do this on each and every word document, only
the one's that are password protected.

Is there a way, using vbscript, to determine whether or not a word
document is password protected? I'm sure there's some tag in the file
that says "yes, you need a password to open", but I'm not intelligent
enough to figure it out on my own.

Any help would be greatly appreciated.

Chris

My System SpecsSystem Spec
Old 02-09-2009   #2 (permalink)
Al Dunbar


 
 

Re: Office document protection


"chris" <christopher.d.biggs@xxxxxx> wrote in message
news:11d932bf-ff65-4d13-ae14-a4821708c0aa@xxxxxx
Quote:

> I've seen a number of samples to open an Office document (ie. word,
> excel, etc.) that is password protected using VBScript. My problem is
> a bit different. I'm performing a recursive search on a directory and
> its subdirectories for word documents, and then extract information
> from those documents. However, some of the word documents, not all,
> are password protected. Also, not all of the passwords are the same.
> I was thinking that when trying to open the documents to get the
> information, I could put the passwords in an array and then loop
> through the array until the correct password is entered. However, I
> didn't want to have to do this on each and every word document, only
> the one's that are password protected.
>
> Is there a way, using vbscript, to determine whether or not a word
> document is password protected? I'm sure there's some tag in the file
> that says "yes, you need a password to open", but I'm not intelligent
> enough to figure it out on my own.
I don't know, however, if your code attempts to open a passworded document
without supplying the correct password, is it able to detect the failure to
open? If so, just set your script to open every document without a password,
and try the passwords for those documents that fail.

/Al


My System SpecsSystem Spec
Old 02-10-2009   #3 (permalink)
cdbiggs


 
 

Re: Office document protection

Al,

Thanks for the help. Hopefully one day I'll figure out if there's a way to
check prior to opening a docoment for a password. In the meantime, though, I
just open each document with a fake password, and then check the error
code...if there is one, I skip it. It's a workaround, but it will work for
now.

Chris

"Al Dunbar" wrote:
Quote:

>
> "chris" <christopher.d.biggs@xxxxxx> wrote in message
> news:11d932bf-ff65-4d13-ae14-a4821708c0aa@xxxxxx
Quote:

> > I've seen a number of samples to open an Office document (ie. word,
> > excel, etc.) that is password protected using VBScript. My problem is
> > a bit different. I'm performing a recursive search on a directory and
> > its subdirectories for word documents, and then extract information
> > from those documents. However, some of the word documents, not all,
> > are password protected. Also, not all of the passwords are the same.
> > I was thinking that when trying to open the documents to get the
> > information, I could put the passwords in an array and then loop
> > through the array until the correct password is entered. However, I
> > didn't want to have to do this on each and every word document, only
> > the one's that are password protected.
> >
> > Is there a way, using vbscript, to determine whether or not a word
> > document is password protected? I'm sure there's some tag in the file
> > that says "yes, you need a password to open", but I'm not intelligent
> > enough to figure it out on my own.
>
> I don't know, however, if your code attempts to open a passworded document
> without supplying the correct password, is it able to detect the failure to
> open? If so, just set your script to open every document without a password,
> and try the passwords for those documents that fail.
>
> /Al
>
>
>
My System SpecsSystem Spec
Old 02-10-2009   #4 (permalink)
Al Dunbar


 
 

Re: Office document protection


"cdbiggs" <cdbiggs@xxxxxx> wrote in message
news:EBF53BE5-4C36-4587-851C-0F1C999FCD9A@xxxxxx
Quote:

> Al,
>
> Thanks for the help. Hopefully one day I'll figure out if there's a way
> to
> check prior to opening a docoment for a password. In the meantime,
> though, I
> just open each document with a fake password, and then check the error
> code...if there is one, I skip it. It's a workaround, but it will work
> for
> now.
You're welcome, but you don't seem to have understood my suggestion:

try to open document WITHOUT giving a password
if open fails then
for each possible password
try to open document WITH given password
if open succeeds then exit if-block
next
flag error: no password works on this one...
end if

/Al
Quote:

> Chris
>
> "Al Dunbar" wrote:
>
Quote:

>>
>> "chris" <christopher.d.biggs@xxxxxx> wrote in message
>> news:11d932bf-ff65-4d13-ae14-a4821708c0aa@xxxxxx
Quote:

>> > I've seen a number of samples to open an Office document (ie. word,
>> > excel, etc.) that is password protected using VBScript. My problem is
>> > a bit different. I'm performing a recursive search on a directory and
>> > its subdirectories for word documents, and then extract information
>> > from those documents. However, some of the word documents, not all,
>> > are password protected. Also, not all of the passwords are the same.
>> > I was thinking that when trying to open the documents to get the
>> > information, I could put the passwords in an array and then loop
>> > through the array until the correct password is entered. However, I
>> > didn't want to have to do this on each and every word document, only
>> > the one's that are password protected.
>> >
>> > Is there a way, using vbscript, to determine whether or not a word
>> > document is password protected? I'm sure there's some tag in the file
>> > that says "yes, you need a password to open", but I'm not intelligent
>> > enough to figure it out on my own.
>>
>> I don't know, however, if your code attempts to open a passworded
>> document
>> without supplying the correct password, is it able to detect the failure
>> to
>> open? If so, just set your script to open every document without a
>> password,
>> and try the passwords for those documents that fail.
>>
>> /Al
>>
>>
>>

My System SpecsSystem Spec
Old 02-11-2009   #5 (permalink)
cdbiggs


 
 

Re: Office document protection

Al,

Again, thank you. I'll try you code out, however, I forgot to mention that
the scope of the job had changed. It seems the management doesn't want the
password protected documents to be accessed, so I'm having to skip them.
That's the purpose of the 'dummy' password. If I were to come upon a
password protected document, using the dummy pword, I'll get an error. I
just check for the error code, skip the document, and then go to the next.

Again, thanks for the suggestion. I'll keep this in mind, because we all
know that management has a bad habit of changing.

Chris

"Al Dunbar" wrote:
Quote:

>
> "cdbiggs" <cdbiggs@xxxxxx> wrote in message
> news:EBF53BE5-4C36-4587-851C-0F1C999FCD9A@xxxxxx
Quote:

> > Al,
> >
> > Thanks for the help. Hopefully one day I'll figure out if there's a way
> > to
> > check prior to opening a docoment for a password. In the meantime,
> > though, I
> > just open each document with a fake password, and then check the error
> > code...if there is one, I skip it. It's a workaround, but it will work
> > for
> > now.
>
> You're welcome, but you don't seem to have understood my suggestion:
>
> try to open document WITHOUT giving a password
> if open fails then
> for each possible password
> try to open document WITH given password
> if open succeeds then exit if-block
> next
> flag error: no password works on this one...
> end if
>
> /Al
>
Quote:

> > Chris
> >
> > "Al Dunbar" wrote:
> >
Quote:

> >>
> >> "chris" <christopher.d.biggs@xxxxxx> wrote in message
> >> news:11d932bf-ff65-4d13-ae14-a4821708c0aa@xxxxxx
> >> > I've seen a number of samples to open an Office document (ie. word,
> >> > excel, etc.) that is password protected using VBScript. My problem is
> >> > a bit different. I'm performing a recursive search on a directory and
> >> > its subdirectories for word documents, and then extract information
> >> > from those documents. However, some of the word documents, not all,
> >> > are password protected. Also, not all of the passwords are the same.
> >> > I was thinking that when trying to open the documents to get the
> >> > information, I could put the passwords in an array and then loop
> >> > through the array until the correct password is entered. However, I
> >> > didn't want to have to do this on each and every word document, only
> >> > the one's that are password protected.
> >> >
> >> > Is there a way, using vbscript, to determine whether or not a word
> >> > document is password protected? I'm sure there's some tag in the file
> >> > that says "yes, you need a password to open", but I'm not intelligent
> >> > enough to figure it out on my own.
> >>
> >> I don't know, however, if your code attempts to open a passworded
> >> document
> >> without supplying the correct password, is it able to detect the failure
> >> to
> >> open? If so, just set your script to open every document without a
> >> password,
> >> and try the passwords for those documents that fail.
> >>
> >> /Al
> >>
> >>
> >>
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Microsoft Office Document Scanning Errors Microsoft Office
Document Copy Protection .NET General
Word '07 Document protection - Protecting certain areas on a doc Vista security
Office 2007 word document Vista mail
Office 97 Pro document converts to '2 month trial' Office 2007 for Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46