Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

Application.CreateObject Method

Office 2007
Creates an Automation object of the specified class.

Syntax

expression.CreateObject(ObjectName)

expression   A variable that represents an Application object.

Parameters

NameRequired/OptionalData TypeDescription
ObjectNameRequiredStringThe class name of the object to create. For information about valid class names, see OLE Programmatic Identifiers.

Return Value
An Object value that represents the new Automation object instance. If the application is already running, CreateObject will create a new instance.

Remarks

This method is provided so that other applications can be automated from Microsoft Visual Basic Scripting Edition (VBScript) 1.0, which did not include a CreateObject method. CreateObject has been included in VBScript version 2.0 and later. This method should not be used to automate Microsoft Outlook from VBScript.

Bb219891.vs_note(en-us,office.12).gif  Note
The CreateObject methods commonly used in the example code within this Help file (available when you click "Example") are made available by Microsoft Visual Basic or Microsoft Visual Basic for Applications (VBA). These examples do
not
use the same CreateObject method that is implemented as part of the object model in Outlook.

Example

This VBScript example uses the Open event of the item to access Windows Internet Explorer and display the Web page.

Visual Basic Scripting Edition
Sub Item_Open()
   Set Web = CreateObject("InternetExplorer.Application")
   Web.Visible = True
   Web.Navigate "www.microsoft.com"
End Sub

This VBScript example uses the Click event of a CommandButton control on the item to access Microsoft Word and open a document in the root directory named "Resume.doc".

Visual Basic Scripting Edition
Sub CommandButton1_Click()
    Set Word = Application.CreateObject("Word.Application")
    Word.Visible = True
    Word.Documents.Open("C:\Resume.doc")
End Sub



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.