Use OleObjects in Code

You can create new linked and embedded objects dynamically by using the OleObjects Add method. For embedded objects, the Add method requires that you know the programmatic ID (progID) of the object you are creating. For linked objects, you can simply provide the source file name. Table 10-1 lists the progIDs of the most common objects.

Table 10-1. ProgIDs of common Office objects

Application

Object

ProgID

Controls

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

 

Calendar

MSCal.Calendar

Microsoft Access

Application

Access.Application

 

CodeData

Access.CodeData

 

CurrentData

Access.CurrentData

 

CodeProject

Access.CodeProject

 

CurrentProject

Access.CurrentProject

 

DefaultWebOptions

Access.DefaultWebOptions

Microsoft Excel

Add-in

Excel.AddIn

 

Application

Excel.Application

 

Chart

Excel.Chart

 

Worksheet

Excel.Sheet

Microsoft Graph

Application

MSGraph.Application

 

Chart

MSGraph.Chart

Microsoft Office Web Components

ChartSpace

OWC.Chart

 

DataSourceControl

OWC.DataSourceControl

 

ExpandControl

OWC.ExpandControl

 

PivotTable

OWC.PivotTable

 

RecordNavigationControl

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.