Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
How to create an automation project using MFC and a type library
Article ID: 178749 - View products that this article applies to.
This article was previously published under Q178749
This article illustrates, in detail, how to automate component integration with COM-compliant applications such as the Microsoft Office applications.
The following section illustrates how you can create an MFC project. The example automates Microsoft Excel. You can use the first 8 steps for any project, and modify steps 9 through 15 when you work with another application.
Create an automation project
Additional NotesOnce you have added the classes from a type library to your project (as you did in step 9 above), you will notice that many classes have been added to the project. In ClassView, you can double-click a class to see the member functions of that class and then double-click the member function to view the definition of that function in the Excel8.cpp implementation file.
You need to go to the definition of a member function if you wish to verify a return type or if you need to change a function's implementation. Any time you change a function definition, remember to change the declaration in the Excel8.h file. When doing so, be sure that you change the correct function declaration; sometimes, the same name is given to member functions of multiple classes--GetApplication() is one such example.
Although the steps above illustrate how to automate Microsoft Excel, you can apply the same ideas to automating other applications. The list below contains the file names for the type libraries of the Microsoft Office applications:
NOTE: The default location for these type libraries is C:\Program Files\Microsoft Office\Office (for Office 2002 the path is C:\...\Office10 and for Office 2003 the path is C:\...\Office11), except for Dao350.dll or Dao360.dll, and Microsoft Office 10(MSO.dll). The default location for Dao350.dll/Dao360.dll is C:\Program Files\Common Files\Microsoft Shared\Dao. The default location for MSO.dll is C:\Program Files\Common Files\Microsoft Shared\Office10 for Office 2002 and C:\Program Files\Common Files\Microsoft Shared\Office11 for Office 2003.
Application Type Library -------------------------------------------------- Microsoft Access 97 Msacc8.olb Microsoft Jet Database 3.5 DAO350.dll Microsoft Binder 97 Msbdr8.olb Microsoft Excel 97 Excel8.olb Microsoft Graph 97 Graph8.olb Microsoft Office 97 Mso97.dll Microsoft Outlook 97 Msoutl97.olb Microsoft PowerPoint 97 Msppt8.olb Microsoft Word 97 Msword8.olb Microsoft Access 2000 Msacc9.olb Microsoft Jet Database 3.51 DAO360.dll Microsoft Binder 2000 Msbdr9.olb Microsoft Excel 2000 Excel9.olb Microsoft Graph 2000 Graph9.olb Microsoft Office 2000 Mso9.dll Microsoft Outlook 2000 Msoutl9.olb Microsoft PowerPoint 2000 Msppt9.olb Microsoft Word 2000 Msword9.olb Microsoft Access 2002 Msacc.olb Microsoft Excel 2002 Excel.exe Microsoft Graph 2002 Graph.exe Microsoft Office 2002 MSO.dll Microsoft Outlook 2002 MSOutl.olb Microsoft PowerPoint 2002 MSPpt.olb Microsoft Word 2002 MSWord.olb Microsoft Office Access 2003 Msacc.olb Microsoft Office Excel 2003 Excel.exe Microsoft Graph 2003 Graph.exe Microsoft Office 2003 MSO.dll Microsoft Office Outlook 2003 MSOutl.olb Microsoft Office PowerPoint 2003 MSPpt.olb Microsoft Office Word 2003 MSWord.olb
This article presents a specific approach to building a dialog-box project. If you would like to see more general documentation about the process of building a VC++ project in the Microsoft Developer Studio environment, there is an excellent tutorial you can access by using Visual Studio InfoView. To access the tutorial, click Search on the Help menu. Click the index tab and type the following:
working with projectsClick List Topics. Select the topic "Home Page: Working With Projects" and click Display. For more information about the automation of Office applications, click the following article number to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/222101/ )How to find and use Office object model documentation
Article ID: 178749 - Last Review: June 23, 2005 - Revision: 4.3