Re: Using COM object's enum by mr
mr
Fri Jan 07 16:49:13 CST 2005
hi Sa,
The reason mikHar asked about the host is that there are standard
methods for making typelib enummed constants available to script
code in IE or wsh hosted scripts. That is, object tags and reference
tags.
It sounds like you are using a script control to add scripting to your
app, and unfortunately there is no standard way to include a typelib
in a script control hosted script.
Therefore you are going to have to resort to "magic".
In this instance, the definition of "magic" is: "If you want to pull a
rabbit out of the hat, you first have to put the rabbit into the hat".
In other words, you are going to have to pre-define the constants
you wish to make available to your users, and place those constants
in a "module".
Presumably, your users are going to be writing their script code in a
multiline textbox (or something similiar), and you app will then take the
code and insert it into the script control.
Along with the users code, I am suggesting that you also insert your
module with the predefined constants you wish to make available to
your users into the script control, giving the module with the constants
"global scope" (i.e., the constants will then be available to any code
entered in the script control.
That should to it.
cheers, jw
"Sa" <ksadf@sdkaew.org> wrote in message
news:eC4b6798EHA.2196@TK2MSFTNGP11.phx.gbl...
> Hello,
>
> I would like to know how to use a COM object's enum in VBScript?
>
> For example:
>
> Set objCN = CreateObject("ADODB.Connection")
> 'objCN.CursorLocation = adUseClient
>
> Note that "adUseClient" is an enum (ADODB.CursorLocationEnum.adUseClient).
>
> Thanks a lot.
>
> Sa
>
>