Word gets stuck when opening from C# service.

R

Raul

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.
 
D

Dennis Lindinger

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 th
word object from an app with GUI is Ok, but when I decided to move the cod
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 cod
using Word = Microsoft.Office.Interop.Word

// word object creatio
_oWordApp = new Word.Application()
_oWord.ActivePrinter = "fax"

// openening the do
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 merg
_oWordDoc.MailMerge.OpenDataSource("source name", ref missing,......

// select the doc and merg
_oWordSelection = _oWordApp.Selection
_oWordMailMerge = _oWordDoc.MailMerge

// print i
_oWordMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter
_oWordMailMerge.Execute(false)
// close do
// close ap

Best regards

raul.

Previous Posts In This Thread:

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 th
word object from an app with GUI is Ok, but when I decided to move the cod
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 cod
using Word = Microsoft.Office.Interop.Word

// word object creatio
_oWordApp = new Word.Application()
_oWord.ActivePrinter = "fax"

// openening the do
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 merg
_oWordDoc.MailMerge.OpenDataSource("source name", ref missing,......

// select the doc and merg
_oWordSelection = _oWordApp.Selection
_oWordMailMerge = _oWordDoc.MailMerge

// print i
_oWordMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter
_oWordMailMerge.Execute(false)
// close do
// close ap

Best regards

raul.


Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Reflection Effect
http://www.eggheadcafe.com/tutorial...-beab-49bd76e20b9b/wpf-reflection-effect.aspx
 

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