Creating, opening and printing a word file from C++ Creating, opening and printing a word file from C++ windows windows

Creating, opening and printing a word file from C++


You can use Office Automation for this task. You can find answers to frequently asked questions about Office Automation with C++ at http://support.microsoft.com/kb/196776 and http://support.microsoft.com/kb/238972 .

Keep in mind that to do Office Automation with C++, you need to understand how to use COM.

Here are some examples of how to perform various tasks in word usign C++:

Most of these samples show how to do it using MFC, but the concepts of using COM to manipulate Word are the same, even if you use ATL or COM directly.


As posted as an answer to a similar question, I advise you to look at this page where the author explains what solution he took to generate Word documents on a server, without MsWord being available, without automation or thirdparty libraries.


When you have the file and just want to print it, then look at this entry at Raymond Chen's blog. You can use the verb "print" for printing.

See the shellexecute msdn entry for details.