471,627 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

How to know if a doc file has password?

Hi!

How to know if a .doc file has password?

Thanks!
Jan 24 '06 #1
3 2431
Kevin,

When you load the document, you should be able to check the HasPassword
property to determine if it has a password or not.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kevin" <@> wrote in message news:u$**************@TK2MSFTNGP09.phx.gbl...
Hi!

How to know if a .doc file has password?

Thanks!

Jan 24 '06 #2
This is my code:

NullObject = System.Reflection.Missing.Value;
DocFile = docFile.FileInfo.FullName;
ReadOnly = true;
IsVisible = false;
WordApp = new Word.ApplicationClass();
WordDoc = WordApp.Documents.Open(ref DocFile, ref NullObject, ref ReadOnly,
ref NullObject,
ref NullObject, ref NullObject, ref NullObject, ref NullObject, ref
NullObject, ref NullObject,
ref NullObject, ref IsVisible, ref NullObject, ref NullObject, ref
NullObject);

When the "Open" method is executed and the .doc file has password the word
application has opened and ask for the password.
I need to know if thie doc has password before execute the "Open".

Is there any way?

Thanks!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> escribió
en el mensaje news:ef**************@TK2MSFTNGP10.phx.gbl...
Kevin,

When you load the document, you should be able to check the HasPassword
property to determine if it has a password or not.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kevin" <@> wrote in message news:u$**************@TK2MSFTNGP09.phx.gbl...
Hi!

How to know if a .doc file has password?

Thanks!


Jan 24 '06 #3
Kevin,

Unfortunately, no, I don't think that there is a way to determine this
before you open the document.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kevin" <@> wrote in message news:e4*************@TK2MSFTNGP15.phx.gbl...
This is my code:

NullObject = System.Reflection.Missing.Value;
DocFile = docFile.FileInfo.FullName;
ReadOnly = true;
IsVisible = false;
WordApp = new Word.ApplicationClass();
WordDoc = WordApp.Documents.Open(ref DocFile, ref NullObject, ref
ReadOnly, ref NullObject,
ref NullObject, ref NullObject, ref NullObject, ref NullObject, ref
NullObject, ref NullObject,
ref NullObject, ref IsVisible, ref NullObject, ref NullObject, ref
NullObject);

When the "Open" method is executed and the .doc file has password the word
application has opened and ask for the password.
I need to know if thie doc has password before execute the "Open".

Is there any way?

Thanks!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
escribió en el mensaje news:ef**************@TK2MSFTNGP10.phx.gbl...
Kevin,

When you load the document, you should be able to check the
HasPassword property to determine if it has a password or not.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kevin" <@> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...
Hi!

How to know if a .doc file has password?

Thanks!



Jan 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by ruca | last post: by
7 posts views Thread by nonameisfree | last post: by
4 posts views Thread by apriebe47 | last post: by
1 post views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.