Discussion:
Connecting AS400 simulator through vbscript
(too old to reply)
j***@gmail.com
2018-04-26 06:28:32 UTC
Permalink
Hi,

I can record a macro from client access in vbscript language.

I want to mimic same steps using my vbscript by creating .vbs file. I am not able to establish connection through vbs file but same can be achieved by vba macro by using following commands.
OPTION EXPLICIT
dim autECLCon, autECLs , autECLO

Set autECLCon = CreateObject("PCOMM.autECLConnList")
Set autECLs = CreateObject("PCOMM.autECLPS")
Set autECLO = CreateObject("PCOMM.autECLOIA")

''' Initialize the session
autECLCon.Refresh
autECLs.SetConnectionByHandle (autECLCon(1).Handle)
autECLO.SetConnectionByHandle (autECLCon(1).Handle)

autECLs.startcommunication
autECLO.WaitForAppAvailable

Please help.

Jasdeep
Mayayana
2018-04-26 11:39:55 UTC
Permalink
<***@gmail.com> wrote

| autECLs.SetConnectionByHandle (autECLCon(1).Handle)
| autECLO.SetConnectionByHandle (autECLCon(1).Handle)
|

Is Handle a variant or a long?

You might want to look at the typelib, assuming
VBA provides an object browser. If not, you can find
one online.

There are two limitations with script.

1) You can't get early binding, which VB/VBA can do
by linking to the typelib and then doing like so:

Dim autECLCon as PCOMM.autECLConnList

If CreateObject works then you should be OK on
that score.

2) There are no datatypes except variant. In most
cases, to use a COM object, that object has to provide
methods that use variants. Sometimes it will work to
do something like:

autECLs.SetConnectionByHandle CLng(autECLCon(1).Handle)

(Your parentheses are not otherwise necessary. You
only need them with functions.)

In that case VBS seems to be able to pass a Long
integer value. But I've only tried it with rare Windows
methods. I think BrowseForFolder used to accomodate
it. So I don't know for certain that it will work in general.
Also, if you have a defined datatype returned by a
function then you're out of luck. In that case your
only option would be to write a VB DLL to cater to
VBS.

Loading...