Using the Microsoft Word Automation Interfaces with the Measurement Studio CNiWordDocument ClassPrimary Software: Measurement Studio>>Visual C++ SupportPrimary Software Version: 6.0 Primary Software Fixed Version: 7.1 Secondary Software: N/A
Problem: I am using the Measurement Studio CNiWordDocument class to automate Microsoft Word, but there is some functionality that it does not provide. I know the Microsoft Word Automation interfaces (or the Word Object Model) provides the functionality that I need. How can I use the CNiWordDocument to easily set up my document and then use the advanced functionality provided by the Microsoft Word automation interfaces? Solution: Measurement Studio provides class libraries to simplify report generation and automation for Micrsoft Word and Excel. A list of the top-level classes and overview of these classes can be found in the Measurement Studio help topics Microsoft Excel Interface Visual C++ Class Library Overview and Microsoft Word Interface Visual C++ Class Library Overview. These classes are not meant to replicate all the functionality that is provided by their respective automation interfaces. But, you can pass the references created by the CNiWord and CNiExcel classes to their respective automation classes to provide the advanced functionality desired. The following code snippet describes how you can use a CNiWordDocument class to create a Word document, and then pass the reference to that existing document to the Word automation interface to move the margins of the document. The CNiWordDocument class does not provide any functionality for modifying the document margins, so using the Word automation interface is the only way to do this. Add the following to your stdafx.h (this example assumes you are using Office XP; the paths will change if you have a different version of Office): In your main code, create the document using the CNiWordDocument class and pass a reference of that document to the Microsoft Word Automation interfaces. For more information about the functionality provided by the Measurement Studio CNiWord and CNiExcel classes, refer to the Measurement Studio class function reference help. For more information about the Microsoft Word and Microsoft Excel Automation interfaces, refer to the link in the Related Links section. Related Links: MSDN KB: How to find and use Office object model documentation Attachments:
Report Date: 07/26/2005 Last Updated: 05/07/2006 Document ID: 3NPG085B |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
