Name
CreateObject Function
Syntax
CreateObject(servername, progID [, location])
servernameUse: Required
Data Type: String
The name of application providing the object.
ProgIDUse: Required
Data Type: String
The programmatic identifier (ProgID) of the object to create, as defined in the system registry.
LocationUse: Optional
Data Type: String
The name of the server where the object is to be created.
Return Value
A reference to an ActiveX object.
Description
Creates an instance of an OLE Automation (ActiveX) object. Prior to calling the methods, functions, or properties of an object, you are required to create an instance of that object. Once an object is created, you reference it in code using the object variable you defined.
Rules at a Glance
In order to assign the object reference to a variable, you must use the
Setkeyword. For example:Dim oDoc Set oDoc = CreateObject("Word.Document")Programmatic identifiers use a string to identify a particular COM component or COM-enabled application. They are included among the subkeys of
HKEY_CLASSES_ROOTin the system registry.Some common programmatic identifiers are shown in the following table:
ProgID | Description |
| An ActiveX Data Objects connection |
| An ActiveX Data Objects recordset |
| Data Access Objects |
| Microsoft Excel |
| A Microsoft Excel chart |
| A Microsoft Excel workbook |
| Collaborative Data Objects |
| Microsoft Outlook |
| Dictionary ... |