Referencing Word Document through C#

G

Guest

Hi all,

I am generated some reports in Word format. While generating them, I have to
protect the document from accidental changes...The following is what I have
done.

object fileNameObj=(Object)stringFileName;
object novalue=System.Reflection.Missing.Value;
object isVisible = true;
object readOnly = false;
object noPrompt = false;
object originalFormat = Type.Missing;
object saveChanges = Word.WdSaveOptions.wdSaveChanges;
object routeDocument = Type.Missing;

Word.ApplicationClass objWord = new Word.ApplicationClass();

Word.Document objWordDoc = objWord.Documents.Open(ref fileNameObj, ref
novalue, ref readOnly , ref novalue, ref novalue,ref novalue,ref novalue,ref
novalue,ref novalue,ref novalue,ref novalue,ref isVisible);

objWord.Documents.Save(ref noPrompt, ref originalFormat);

objWord.Documents.Close(ref saveChanges, ref novalue, ref novalue);

objWord.Quit(ref novalue, ref novalue, ref novalue);

The problem is that by doing so, t he protection takes place properly..but
the word documents open each time...this is very frustrating because many
documents are generated and each one gets opened.

Is there any other way to reference a word document such that i get hold of
the document without opening it ? ..

I know I can do something like
objWord.Documents.Item(index) ...but how do i know what the index of the
current document is ? how do i add it to the Documents Collection ?

Any thoughts would be appreciated.
Thanks,
-swe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top