Article ID: 183284 - Last Review: August 27, 2007 - Revision: 2.2 INFO: CreateObject in VBScriptThis article was previously published under Q183284 SUMMARY
The versions (1.0) of the VBScript engine that shipped with Internet
Explorer 3.0x did not support the CreateObject function, which is commonly
available in Visual Basic for Applications and Visual Basic.
As of version 2.0, VBScript supports the CreateObject function. If the 2.0 (or higher) version of these engines has been installed on a client machine, the CreateObject function is supported in client-side script embedded inside an HTML page when using Internet Explorer 3.0x. MORE INFORMATION
VBScript 2.0 shipped with the Active Server Pages (ASP) component of
Internet Information Server (IIS) 3.0. ASP is used to produce server-side
script inside .asp files. ASP has always supported CreateObject. The rest
of this article refers to the use of CreateObject in client-side script,
which is evaluated by Internet Explorer 3.x, not ASP server-side script.
The VBScript CreateObject function works in the conventional manner: it takes one string parameter and returns an object. The string parameter should refer to the ProgID of a valid Automation object installed on the client system. Here is an example CreateObject call: When using CreateObject, you may get the following scripting error: For information on marking objects safe for scripting, please see the following articles in the Microsoft Knowledge Base: 164119
(http://support.microsoft.com/kb/164119/EN-US/
)
SAMPLE: Implementing IObjectSafety in an ActiveX Control
Note that the registry entries mentioned in these articles could be used on
a client machine to mark any object as safe for scripting. This is
recommended only in internal environments where the safety of objects in
Web pages can be guaranteed and the use of an object that is not safe for
scripting is necessary. These registry entries need to be applied by the
client and cannot be forced on a client through script code.
161873 (http://support.microsoft.com/kb/161873/EN-US/ ) HOWTO: Mark MFC Controls Safe for Scripting/Initialization To conditionally test for the engine version currently installed on the client machine, and consequently whether the client supports CreateObject, the ScriptEngineMajorVersion function can be used in both VBScript and JScript. Here is an example snippet of VBScript code: REFERENCES
To obtain the latest version of Microsoft scripting engines and see the
latest Microsoft scripting news, visit the scripting Web site at:
http://www.microsoft.com/technet/scriptcenter/default.mspx
(http://www.microsoft.com/technet/scriptcenter/default.mspx)
APPLIES TO
| Article Translations
|

Back to the top
