Solved

Open Password protected Word Document from C#

Posted on 2003-12-04
4
915 Views
Last Modified: 2007-12-19
Hi
 I need to open a word document in C# . The word document has a password.
The code is :

object fileName = openFileDialog1.FileName;
object passwd = "BOSSPASS";
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
string fname;
WordApp = new Word.ApplicationClass();
             
WordApp.Activate();
WordApp.Visible = true;
      
Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,ref readOnly,
ref missing, ref passwd, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);

I am passing the passwd to the open statements. Still it opens the word document and prompts to enter the password.

Kindly help me to solve this problem.
Thanks in Advance,
sudha



0
Comment
Question by:Sudhabalu
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
_TAD_ earned 200 total points
ID: 9885869



You are missing some references....


<Your Code>
Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,ref readOnly,
ref missing, ref passwd, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);

<My Code>
Word.Document aDoc = WordApp.Documents.Open(ref docPath, ref missing, ref readOnly,
ref missing, ref password, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible,
ref missing, ref missing, ref missing);

aDoc.Activate();
WordApp.Visible = true;
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 9885886

"you are missing some missing statements"

does the above statement make sense??  

eh... you'll figure it out
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now