Office Open XML Help

rocky050371
rocky050371 used Ask the Experts™
on
I am looking at switching my current windows service from running DCOM (Interop) to Open XML. The service essentially opens a word document, loops through merge fields, saves the document then prints it.

Does anyone have any code examples or books / Sites which explain this in more detail?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:

Author

Commented:
Do you know whether it is possible to print to a specified printer in the same way you can with the word object model
Most Valuable Expert 2012
Top Expert 2014

Commented:
I don't think you can do that because OpenXML is just generating a document. It has nothing to do with Word which would actually do the printing.
Commented:
You are right to avoid Word altogether in the service, because Office applications are not meant to be automated out of the desktop environment.

One thing you could try.

1. Create your template in Word, and save as RTF, then use string methods to do your mail merge.  See my answer here:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24234418.html

2. Print your RTF with code like this:
How to print the content of a RichTextBox control by using Visual Basic .NET
http://support.microsoft.com/kb/811401/EN-US

Well, that sample is winforms, but you should be able to use the printdocument without the preview control and all that.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial