Solved

Open Password protected Word Document from C#

Posted on 2003-12-04
4
877 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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

14 Experts available now in Live!

Get 1:1 Help Now