Hello Raul,
I am having similar trouble. I have a service that opens and prints word documents. It works fine as a service on windows server 2003, but the _oWordDoc object comes back as null on windows server 2008. I was just wondering if you had resolved your issue and if you might be able to offer any insight.
Dennis
Raul wrote:
Word gets stuck when opening from C# service.
29-Jan-07
Hi there,
I have a C# app that calls Office.Inetrop.Word to do Mail Merge. Calling the
word object from an app with GUI is Ok, but when I decided to move the code
to a service, it gets stuck in Word.Open function.
I have a template that I open, and then do mail merge on it to fax it.
Is there any known problem with word object and services?
pieces of the code
using Word = Microsoft.Office.Interop.Word;
// word object creation
_oWordApp = new Word.Application();
_oWord.ActivePrinter = "fax";
// openening the doc
object missing System.Reflection.MissingValue;
object oDocName = "word template name.doc";
_oWordDoc = _oWordApp.Documents.Open(ref oDocName, ref missing, ref missing,
ref missing, ref missing,
ref missing,
ref missing, ref missing,
ref missing,
ref missing, ref missing,
ref missing,
ref missing, ref missing,
ref missing,
ref missing);
_oWordDoc.Select();
// mail merge
_oWordDoc.MailMerge.OpenDataSource("source name", ref missing,......)
// select the doc and merge
_oWordSelection = _oWordApp.Selection;
_oWordMailMerge = _oWordDoc.MailMerge;
// print it
_oWordMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter;
_oWordMailMerge.Execute(false);
// close doc
// close app
Best regards,
raul.
Previous Posts In This Thread:
On Monday, January 29, 2007 3:42 PM
Raul wrote:
Word gets stuck when opening from C# service.
Hi there,
I have a C# app that calls Office.Inetrop.Word to do Mail Merge. Calling the
word object from an app with GUI is Ok, but when I decided to move the code
to a service, it gets stuck in Word.Open function.
I have a template that I open, and then do mail merge on it to fax it.
Is there any known problem with word object and services?
pieces of the code
using Word = Microsoft.Office.Interop.Word;
// word object creation
_oWordApp = new Word.Application();
_oWord.ActivePrinter = "fax";
// openening the doc
object missing System.Reflection.MissingValue;
object oDocName = "word template name.doc";
_oWordDoc = _oWordApp.Documents.Open(ref oDocName, ref missing, ref missing,
ref missing, ref missing,
ref missing,
ref missing, ref missing,
ref missing,
ref missing, ref missing,
ref missing,
ref missing, ref missing,
ref missing,
ref missing);
_oWordDoc.Select();
// mail merge
_oWordDoc.MailMerge.OpenDataSource("source name", ref missing,......)
// select the doc and merge
_oWordSelection = _oWordApp.Selection;
_oWordMailMerge = _oWordDoc.MailMerge;
// print it
_oWordMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter;
_oWordMailMerge.Execute(false);
// close doc
// close app
Best regards,
raul.
Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Reflection Effect
http://www.eggheadcafe.com/tutorials/aspnet/8cc84aa8-3b44-4037-beab-49...6e20b9b