Skip to Main Content
VBScript in a Nutshell, 2nd Edition
book

VBScript in a Nutshell, 2nd Edition

by Paul Lomax, Matt Childs, Ron Petrusha
March 2003
Intermediate to advanced content levelIntermediate to advanced
512 pages
14h 30m
English
O'Reilly Media, Inc.
Content preview from VBScript in a Nutshell, 2nd Edition

Name

CreateObject Function

Syntax

CreateObject(servername, progID [, location])
servername

Use: Required

Data Type: String

The name of application providing the object.

ProgID

Use: Required

Data Type: String

The programmatic identifier (ProgID) of the object to create, as defined in the system registry.

Location

Use: 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 Set keyword. 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_ROOT in the system registry.

  • Some common programmatic identifiers are shown in the following table:

ProgID

Description

ADODB.Connection

An ActiveX Data Objects connection

ADODB.Recordset

An ActiveX Data Objects recordset

DAO.DBEngine

Data Access Objects

Excel.Application

Microsoft Excel

Excel.Chart

A Microsoft Excel chart

Excel.Sheet

A Microsoft Excel workbook

MAPI.Session

Collaborative Data Objects

Outlook.Application

Microsoft Outlook

Scripting.Dictionary

Dictionary ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

VBScript in a Nutshell

VBScript in a Nutshell

Matt Childs, Paul Lomax, Ron Petrusha
Microsoft® PowerShell, VBScript and JScript® Bible

Microsoft® PowerShell, VBScript and JScript® Bible

William R. Stanek, James O'Neill, Jeffrey Rosen

Publisher Resources

ISBN: 0596004885Errata Page