Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open password protected word with Interop

Status
Not open for further replies.

Leonos

Programmer
Sep 17, 2003
32
NL
I want to print Word documents with the help of the office.Interop.Word library.
So far I had no problems, but today i received a password protected file.

Now my application hangs on opening the word file.

How can I check if the file is password protected or is there a way to generate an exeption when the file is protected.

I use:
Microsoft.Office.Interop.Word.ApplicationClass myClass = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Application myAppl = myClass.Application;
Microsoft.Office.Interop.Word.Document document = myAppl.Documents.OpenOld(ref filename, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue);

At the last (openold), my application hangs.

Or is there a way to generate a timeout for this ?

 
I think you can do document.HasPassword to check.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top