This article was previously published under Q234788
This article demonstrates how to use the Windows Installer to find the installation path of Microsoft Office applications.
Versions of Microsoft Office greater than 2000 do not include path information in the shortcut links when installed. This is done so that the "Run on First Use" option can be used. When this option is used, the shortcuts will appear, but the applications will not be installed on the hard disk. When you click on the shortcut for the first time, the applications will be installed.
You can use the Windows Installer to get the path of the installed Office 2000 application. Follow the steps given below to create a console application that reports the directory of an installed Office application.
Building the Sample
Create a blank console application in Visual C++.
Create a new file called main.cpp and paste the following code in the code window.
Click the Project menu and then click Settings to bring up the project settings dialog box.
Click the Link tab and add msi.lib in the list of Object/library modules.
Run the program. It will display the file path where Microsoft Word is installed.
NOTE: Included in the code are the GUIDS associated with Word, Excel, PowerPoint and Access. To find the path for another Office application, pass in the name of the application as the second parameter of the MsiGetComponentPath function.
To find the path of an Office XP application, replace the constants above with the following.
Microsoft Office Access 2007, Microsoft Office Excel 2007, Microsoft Office PowerPoint 2007, Microsoft Office Word 2007, Microsoft Office Access 2003, Microsoft Office PowerPoint 2003, Microsoft Access 2002 Standard Edition, Microsoft Excel 2002 Standard Edition, Microsoft PowerPoint 2002 Standard Edition, Microsoft Word 2002, Microsoft Access 2000 Standard Edition, Microsoft Excel 2000 Standard Edition, Microsoft PowerPoint 2000 Standard Edition, Microsoft Word 2000, Microsoft Word 2010, Microsoft Excel 2010, Microsoft PowerPoint 2010, Microsoft Access 2010, Microsoft Office Professional 2010