473,395 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 2458
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jim J | last post by:
I have been trying to find some kind of authentication method or script (PHP/perl/javascript or other) to achieve the following, with no luck. Say there are 100 files at a site. A person can...
1
by: chuck amadi | last post by:
By the way list is there a better way than using the readlines() to > > >parse the mail data into a file , because Im using > > >email.message_from_file it returns > > >all the data i.e reads one...
15
by: ruca | last post by:
Hi, Can I read a .TXT File to a DataSet? How can I do that? I want to read his lines to a DropDownList. This lines are the names of employees that I export from an application that I have. I...
3
by: Henry | last post by:
Hi, my asp.net application is accessing a mssql on another server. This works fine when I use this in my web.config file: <add key="dbkey"...
4
by: kthiagar | last post by:
Hi I am trying to connect to a password protected access file from VB.NET. I have no problem in connecting to Access, if I remove the password. This is what I am doing: In the server explorer,...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
4
by: Jamey Shuemaker | last post by:
A2k2 with user-level security and all preventive measures, vis a vis, Security FAQ enabled or enacted. I've got three DBs, which due to size constraints can't, or rather, probably shouldn't be...
7
by: nonameisfree | last post by:
I am trying to get StartUp-Manager to write the grub password in encrypted form to menu.lst. Currently it writes the password in plain-text and that is not too clever... This is the function I...
4
by: apriebe47 | last post by:
Alright, I realize this is probably very basic to be posted on this newsgroup but I cannot figure out what is causing my problem. Here is the code I am using below: from getpass import getpass ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.