Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Open Password protected Word Document from C#

Posted on 2003-12-04
4
Medium Priority
?
1,145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

722 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