J
Jason Reichenbach
Controlling Word 2003 from a C#.NET application using the COM interface.
I create a Word object and then perform processing on many files (> 100)
sequentially, with Word invisible. Here is the basic code I use:
Word.ApplicationClass Wrd = new Word.ApplicationClass ();
Word.Document aDoc;
foreach (string curFile in FileCollection) {
aDoc = Wrd.Documents.Open (
// Parameters removed for brevity
);
// Perform document processing on aDoc
aDoc.Close (...);
} // End foreach
Wrd.Quit (...);
This all works fine, Word and the documents stay invisible and all is well.
Unless the user opens another instance of Word while this processing is
underway. Then, the automated instance of Word becomes visible and takes
over, so that the user cannot gain access to the document they wanted to work
on manually (separate from the automated work going on).
Is there any way to avoid this problem? From reading the Word Help, it seems
like maybe the /N startup parameter might work, but I have not found how to
do that using the COM interface to Word.
Specific questions:
1) Is there a way to avoid this interference between Word instances?
2) If 1) is Yes, is the /N parameter the way to do it?
3) If 2) is Yes, how can I duplicate the /N when creating a Word instance
via COM?
Any help will be most appreciated.
Thanks in advance.
I create a Word object and then perform processing on many files (> 100)
sequentially, with Word invisible. Here is the basic code I use:
Word.ApplicationClass Wrd = new Word.ApplicationClass ();
Word.Document aDoc;
foreach (string curFile in FileCollection) {
aDoc = Wrd.Documents.Open (
// Parameters removed for brevity
);
// Perform document processing on aDoc
aDoc.Close (...);
} // End foreach
Wrd.Quit (...);
This all works fine, Word and the documents stay invisible and all is well.
Unless the user opens another instance of Word while this processing is
underway. Then, the automated instance of Word becomes visible and takes
over, so that the user cannot gain access to the document they wanted to work
on manually (separate from the automated work going on).
Is there any way to avoid this problem? From reading the Word Help, it seems
like maybe the /N startup parameter might work, but I have not found how to
do that using the COM interface to Word.
Specific questions:
1) Is there a way to avoid this interference between Word instances?
2) If 1) is Yes, is the /N parameter the way to do it?
3) If 2) is Yes, how can I duplicate the /N when creating a Word instance
via COM?
Any help will be most appreciated.
Thanks in advance.