OLE Programmatic Identifiers (Project)
You can use an OLE programmatic identifier (sometimes called a ProgID) to create an Automation object. For example, if both Microsoft Project 2010 and Microsoft Word are installed on the computer, the following macro in Project creates a Word document, and then opens the Save As dialog box in Word.
Sub CreateWordDoc_Late()
Dim wdDoc As Object
Set wdDoc = CreateObject("Word.Document")
wdDoc.Save
End SubO
Note
OLE objects created by using the ProgID have late binding at run time; therefore, you cannot see the object members available when you are writing code in the VBE. Late-bound objects also have poorer performance than objects created with early binding at design time. The following macro performs better and does the same job as CreateWordDoc_Late. The CreateWordDoc_Early macro requires that you add a reference to the Microsoft Word 14.0 Object Library.
Sub CreateWordDoc_Early()
Dim wdDoc As Word.Document
Set wdDoc = New Word.Document
wdDoc.Save
End Sub
For information about using Project from another application, see the Application object.
The following tables list OLE programmatic identifiers for ActiveX controls and Microsoft Office applications.
ActiveX Controls
To create the ActiveX controls listed in the following table, use the corresponding OLE programmatic identifier.
To create this control |
Use this identifier |
---|---|
CheckBox |
Forms.CheckBox.1 |
ComboBox |
Forms.ComboBox.1 |
CommandButton |
Forms.CommandButton.1 |
Frame |
Forms.Frame.1 |
Image |
Forms.Image.1 |
Label |
Forms.Label.1 |
ListBox |
Forms.ListBox.1 |
MultiPage |
Forms.MultiPage.1 |
OptionButton |
Forms.OptionButton.1 |
ScrollBar |
Forms.ScrollBar.1 |
SpinButton |
Forms.SpinButton.1 |
TabStrip |
Forms.TabStrip.1 |
TextBox |
Forms.TextBox.1 |
ToggleButton |
Forms.ToggleButton.1 |
Microsoft Access
To create the Microsoft Access objects listed in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Access that is available on the computer where the macro is running.
To create this object |
Use one of these identifiers |
---|---|
Application |
Access.Application, Access.Application.14 |
CurrentData |
Access.CodeData, Access.CurrentData |
CurrentProject |
Access.CodeProject, Access.CurrentProject |
DefaultWebOptions |
Access.DefaultWebOptions |
Microsoft Excel
To create the Microsoft Excel objects listed in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Excel that is available on the computer where the macro is running.
To create this object |
Use one of these identifiers |
Comments |
---|---|---|
Application |
Excel.Application, Excel.Application.14 |
|
Workbook |
Excel.AddIn |
|
Workbook |
Excel.Chart, Excel.Chart.8 |
Returns a workbook containing two worksheets: one for the chart, and one for its data. The chart worksheet is the active worksheet. |
Workbook |
Excel.Sheet, Excel.Sheet.12 |
Returns a workbook with one worksheet. |
Microsoft Graph
To create the Microsoft Graph objects listed in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Graph that is available on the computer where the macro is running.
To create this object |
Use one of these identifiers |
---|---|
Application |
MSGraph.Application, MSGraph.Application.8 |
Chart |
MSGraph.Chart, MSGraph.Chart.8 |
Microsoft Office Web Components
Note
The Microsoft Office Web Component (OWC) is deprecated and is not installed with Microsoft Project 2010.
Microsoft Outlook
To create the Microsoft Outlook object given in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Outlook that is available on the computer where the macro is running.
To create this object |
Use one of these identifiers |
---|---|
Application |
Outlook.Application, Outlook.Application.14 |
Microsoft PowerPoint
To create the Microsoft PowerPoint object given in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of PowerPoint that is available on the computer where the macro is running.
To create this object |
Use one of these identifiers |
---|---|
Application |
PowerPoint.Application, PowerPoint.Application.14 |
Microsoft Word
To create the Microsoft Word objects listed in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Word that is available on the computer where the macro is running. Word.Document.8 and Word.Document.12 both create a document in the default Open XML format (.docx).
To create this object |
Use one of these identifiers |
---|---|
Application |
Word.Application, Word.Application.14 |
Document |
Word.Document, Word.Document.8, Word.Template.8, Word.Document.12, Word.Template.12 |