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

automation, c++, ms-word, windows

Solution

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++:

- http://support.microsoft.com/kb/220911/en-us

- http://support.microsoft.com/kb/238393/en-us

- http://support.microsoft.com/kb/238611/en-us

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.

Problem

I have three related questions. I want to create a word file with a name from C++. I want to be able to sent the printing command to this file, so that the file is being printed without the user having to open the document and do it manually and I want to be able to open the document. Opening the document should just open word which then opens the file.

Original source

Related problems