Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 239930 - Last Review: March 29, 2007 - Revision: 7.2
How to obtain built-in constant values for an Office application
This article was previously published under Q239930
Microsoft Office applications can act as ActiveX Servers. They provide client applications design-time access to an Object library, or type library, that enables client applications to view an Office application's objects, properties, methods, and constants.
You can use late binding in a Visual Basic automation controller to automate an Office application without the need for referencing the Office application's type library. When you use late binding, you need to use the values for built-in constants for the Office application. This article describes how you can programmatically retrieve a list of built-in constants and the equivalent values at run time.
The following table illustrates which file contains the type library information:
Collapse this tableExpand this table
| Application | Type Library |
| Microsoft Access 2000 | Msacc9.olb |
| 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 Office 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 |
| Microsoft Office Access 2007 | Msacc.olb |
| Microsoft Office Excel 2007 | Excel.exe |
| Microsoft Office Outlook 2007 | MSOutl.olb |
| Microsoft Office PowerPoint 2007 | MSPpt.olb |
| Microsoft Office Word 2007 | MSWord.olb |
Note The default location for these type libraries is:
Collapse this tableExpand this table
| Office Version | Path |
| Office 2000 | C:\Program
Files\Microsoft Office\Office |
| Office XP | C:\Program
Files\Microsoft Office\Office10 |
| Office 2003 | C:\Program
Files\Microsoft Office\Office11 |
| Office 2007 | C:\Program Files\Microsoft Office\Office12 |
To determine information about a type library at run time, use the TypeLibInformation ActiveX object (
tlbinf32.dll) that ships with Visual Studio 6.0. The following sample illustrates how you can use TypeLibInformation to retrieve a list of built-in constants from a type library.
Steps to create the sample program
- Start Microsoft Visual Basic and create a new Standard EXE project. Form1 is created by default.
- From the Project menu, select References, and set a reference to tlbinf32.dll by checking the box containing TypeLib information.
- Place a CommandButton and two TextBoxes on the Visual Basic form.
- Select the second TextBox named Text2 by default, and in the Properties window, set the Multiline property to True. Set the Scrollbar property of Text2 to 2-Vertical.
- Copy the following code into the code window for Form1:
Private Sub Command1_Click()
Text1.Enabled = False
Command1.Enabled = False
Text2.Enabled = True
GetWordConstants (Text1.Text)
End Sub
Private Sub GetWordConstants(strPath As String)
Dim x As TypeLibInfo, sText as String
On Error Resume Next
'Get information from the Word Object library
Set x = TypeLibInfoFromFile(Text1.Text)
For Each r In x.Constants
For Each mbr In r.Members
sText = sText & mbr.Name & " = " & mbr.Value & vbCrLf
Next mbr
Next r
Text2.Text = sText
Set x = Nothing
Text1.Enabled = True
Command1.Enabled = True
End Sub
Private Sub Form_Load()
Form1.WindowState = vbNormal
Command1.Enabled = False
Text1.Text = ""
Text2.Text = ""
Text2.Enabled = False
End Sub
Private Sub Text1_Change()
If Text1.Text <> "" Then
Command1.Enabled = True
End If
End Sub - Run the project. Type in the full path of an Office Object Library file in the first TextBox and click the CommandButton to display type library information in the second TextBox.
Note Tlbinf32.exe is a file that contains the HTML Help file for the TypeLibInformation object. The Tlbinf32.dll file and the HTML Help file are provided for your reference only, and they are not supported by Microsoft.
For more information about using the TypeLibInformation object, please see the following articles in the Microsoft Knowledge Base:
224331Â
(http://kbalertz.com/Feedback.aspx?kbNumber=224331/EN-US/
)
FILE: tlbinf32.exe : Help Files for tlbinf32.dll
172988Â
(http://kbalertz.com/Feedback.aspx?kbNumber=172988/EN-US/
)
FILE: Programmatically Retrieve the Members of a DLL Class
APPLIES TO
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Office Binder 2000
- Microsoft Graph 2002
- Microsoft Graph 2000
- Microsoft Office Access 2007
- Microsoft Office Access 2003
- Microsoft Access 2002 Standard Edition
- Microsoft Access 2000 Standard Edition
- Microsoft Office Outlook 2007
- Microsoft Office Outlook 2003
- Microsoft Outlook 2002 Standard Edition
- Microsoft Outlook 2000 Standard Edition
- Microsoft Office PowerPoint 2007
- Microsoft Office PowerPoint 2003
- Microsoft PowerPoint 2000 Standard Edition
- Microsoft PowerPoint 2002 Standard Edition
- Microsoft Office Word 2007
- Microsoft Office Word 2003
- Microsoft Word 2002
- Microsoft Word 2000
- Microsoft Office Excel 2007
- Microsoft Office Excel 2003
- Microsoft Excel 2002 Standard Edition
- Microsoft Excel 2000 Standard Edition
| kbexpertisebeginner kbautomation kbhowto KB239930 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate