How to find and use Office object model documentation
This article was previously published under Q222101 On This PageSUMMARY
This article describes the resources and documentation available to you for automating Microsoft Office applications. This information can be applied regardless of the programming language you choose for automating an Office application. This article also illustrates how you can begin writing automation code by stepping you through the documentation to find the information you need to accomplish a specific task through automation.
MORE INFORMATIONWhere can I find the object model documentation?The object models for the Office applications are documented in a Language Reference for both versions of Office: Microsoft Office 97 Visual Basic for Applications Language ReferenceISBN 1-57231-339-0 Microsoft Office 2000 Visual Basic for Applications Language Reference ISBN 1-57231-955-0. The Language References are available on the MSDN and in the online Help that ships with Microsoft Office. They can also be purchased in printed form. For ordering information, please visit:
http://mspress.microsoft.com
The following table lists the Help files for each Office application.
The Help files that ship with Microsoft Office 97 are installed by default at:
C:\Program Files\Microsoft Office\Office
If you cannot find the Office 97 VBA Help file you need, it probably was not installed when you initially ran Office 97 setup. To install the Help file, run the Office setup to add the VBA Help file. Note that the Outlook 97 VBA Help file is not installed by Office setup. For information on installing the Outlook 97 VBA Help file, please see the following article in the Microsoft Knowledge Base:
166738 (http://support.microsoft.com/kb/166738/) OL97: How to install Visual Basic Help
The Help files that ship with Microsoft Office 2000 are installed by default at:
C:\Program Files\Microsoft Office\Office\1033
The Help files that ship with Microsoft Office XP are installed by default at:
C:\Program Files\Microsoft Office\Office10\1033
C:\Program Files\Microsoft Office\Office11\1033
NOTE: The Microsoft Office 2000, Microsoft Office XP, and Microsoft Office 2003 Setup programs install the VBA Help files "on first use." Therefore, you might not see the Help file in this directory if you have not previously attempted to access VBA Help in the Office application.How can I use the object model documentation?There are several methods you could use to find documentation for a specific class, method, or property:
How do I know which classes, methods, and properties to use?If you are not already familiar with the object model of the application you intend to automate, you can use the application's Macro Recorder to get an idea. To illustrate, suppose you want to automate Microsoft Word to add some text to a new document and then save the document but you don't know which methods and properties to use; you can start with the Macro Recorder:
Start with examining the first line of the recorded macro: Documents.Add. Highlight Documents on the code module for the Recorded macro and press the F1 key. The Help topic provides you with the following important information:
Upon examination of the recorded macro, you see that the SaveAs method has an argument for which it passes the built-in constant wdFormatDocument. Depending on the programming language you choose for your automation controller, you might need to pass the numeric value for the built-in constants. The Help topic for the SaveAs method does not give this information but you can find it in the Object Browser. Press the F2 key to display the Object Browser. Type: wdFormatDocument in the search window and press the ENTER key. In the bottom pane of the Object Browser, you see the numeric equivalent of wdFormatDocument(=0) as well as other information about the constant. REFERENCESWhere can I find some automation code samples?The information presented so far gives you good groundwork for writing automation code. The Microsoft Knowledge Base is an excellent resource for finding automation code samples written in Visual Basic, Visual C++ and MFC. Here are just a few:For Visual Basic developersFor more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:220595 (http://support.microsoft.com/kb/220595/)
How to automate Outlook using Visual Basic
219151 (http://support.microsoft.com/kb/219151/) How to automate Microsoft Excel from Visual Basic
147650 (http://support.microsoft.com/kb/147650/) How to navigate Excel objects from Visual Basic
142387 (http://support.microsoft.com/kb/142387/) How to create Excel chart w/OLE automation from Visual Basic
184974 (http://support.microsoft.com/kb/184974/) How to use (OLE) automation with Word
220607 (http://support.microsoft.com/kb/220607/) How to automate Microsoft Word to perform mail merge from Visual Basic
222929 (http://support.microsoft.com/kb/222929/) How to automate PowerPoint by using Visual Basic in Office 2003, in Office XP Developer, and in Office 2000 Developer
Visual C++ developers (using MFC)For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:178749 (http://support.microsoft.com/kb/178749/)
How to create an automation project using MFC and a type library
179706 (http://support.microsoft.com/kb/179706/) How to use MFC to automate Excel and create and format a new workbook
186120 (http://support.microsoft.com/kb/186120/) How to use MFC to automate Excel and fill a range with an array
186122 (http://support.microsoft.com/kb/186122/) How to use MFC to automate Excel 2000 and Excel 2002 and obtain an array from a range in Excel 2000 and Excel 2002
220911 (http://support.microsoft.com/kb/220911/) How to automate Microsoft Word to perform a mail merge using Visual C++ and MFC
222960 (http://support.microsoft.com/kb/222960/) How to automate PowerPoint by using Visual C++ 5.0 or Visual C++ 6.0 with The Microsoft Foundation Classes
C/C++ developers (without MFC)For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:216686 (http://support.microsoft.com/kb/216686/)
How to automate Excel from C++ without using MFC or #import
181473 (http://support.microsoft.com/kb/181473/) How to use OLE Automation from a C application rather than C++
Visual J++ developersFor more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:219430 (http://support.microsoft.com/kb/219430/)
How to create/format an Excel workbook using Visual J++ automation
215484 (http://support.microsoft.com/kb/215484/) How to automate PowerPoint by using Visual J++ 6.0
Visual FoxPro developersFor more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:142193 (http://support.microsoft.com/kb/142193/)
How to use OLE Automation to add data to Excel sheet
180901 (http://support.microsoft.com/kb/180901/) How to create a categorized table in Word 97 or in Office Word 2003 from Visual FoxPro for Windows 5.0 and later versions
181926 (http://support.microsoft.com/kb/181926/) How to automate mail merge to Word using OLE and ODBC
194306 (http://support.microsoft.com/kb/194306/) How to make Word print duplex by using OLE automation from Visual FoxPro
230154 (http://support.microsoft.com/kb/230154/) How to automate PowerPoint using Visual FoxPro
241942 (http://support.microsoft.com/kb/241942/) How to prevent Word printing error with BackgroundPrintingStatus property
For additional information, including sample code and resources for automating Microsoft Office, visit the following Microsoft Web site:
http://support.microsoft.com/gp/ofd (http://support.microsoft.com/gp/ofd) APPLIES TO
| Article Translations
|
Back to the top
