Help!

Word gets stuck when opening from C# service.

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Application Errors RSS
Next:  new types of cross-references are not saved after..  
Author Message
Raul
External


Since: Jan 29, 2007
Posts: 3



PostPosted: Mon Jan 29, 2007 3:42 pm    Post subject: Word gets stuck when opening from C# service.
Archived from groups: microsoft>public>word>application>errors (more info?)


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.
Back to top
Dennis Lindinger
External


Since: Apr 13, 2010
Posts: 1



PostPosted: Tue Apr 13, 2010 1:08 pm    Post subject: Follow-up [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Application Errors All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum