Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Open Password protected Word Document from C#

Posted on 2003-12-04
4
Medium Priority
?
1,208 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 800 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

926 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