Defines objects that can be referenced by script.
|
---|
<object id="objID" {classid="clsid:GUID" | progid="progID"} [events="hookevents"] /> |
Values
- objID
A name by which the object can be referenced in your script. Object ID values must begin with a letter and can include letters, digits, and underscores (_). The object ID must be unique throughout the scope of the script component. For example, if you specify the name CObj, you can reference the object in your script this way:
| Copy Code |
---|
x = CObj.Prop1 |
- GUID
(Optional) A reference to the class ID (GUID) under which the object has been registered. Use "clsid:" followed by the class ID (without curly brackets). Either a classid or a progid attribute must be specified. For example:
| Copy Code |
---|
classid="clsid:2154c700-9253-11d1-a3ac-0aa0044eb5f" |
- progID
(Optional) The program ID of the object, which can be specified as an alternative to the class ID. Either a classid or a progid attribute must be specified.
- hookevents
(Optional) A value (either "true" or "false") that determines if you can hook events from the object. By default, hookevents is false. If the attribute is true, you can connect to any events the object may fire. You must add an event handler for each event that is to be handled.
Remarks
Example
The following script component fragment includes an <object> element to create an object reference to the ADODB.Connection object.
| Copy Code |
---|
<registration progid="ADOScriptlet"/>
<object id="cnn" progid="ADODB.Connection"/>
<public>
<property name="cnnState"/>
<method name="openconnection"/>
</public>
<script language="VBScript">
<![CDATA[
Dim cnnState
Function openconnection()
cnn.ConnectionString = "driver={SQL Server};server=<enterserver>;" & _
"uid=<enterlogon>;pwd=<enterpassword>;database=<enterdatabase>"
cnn.Open
If cnn.State = 1 Then
cnnState = "open"
cnn.Close
Else
cnnState = "closed"
End If
End Function
]]>
</script> |
See Also