0
votes

I am trying to connect to an open application and send command to one of it's DLL functions. Here is the code- the error happens on the the GetObject. What am I doing wrong?

Dim oOL
Dim lcCmd

lcCmd = "'QQWOMOD.TWOAuto', '100',False"
MsgBox lcCmd
On Error Resume Next

'The Next stmt is commented out, but gives the same error as the one that follows it
'Set oOL = GetObject("C:\Program Files (x86)\Component Control\Quantum Control\Quantum.exe", "Quantum.SysMod")

Set oOL = GetObject("Quantum.SysMod")
If oOL is Nothing Then
    MsgBox "1- " + Err.Description
    MsgBox "1- " + Err.number
End If

MsgBox ("2")
oOL.InspectWO(lcCmd)
MsgBox("3")
2

2 Answers

-2
votes

Welcome to Stack Overflow. I'm still amazed by the number of people who start programming using ancient VBScript, but let's see this through. :)

The first thing you need to do is avoid using On Error Resume Next wherever possible, since this will mask the true cause of your errors. The error you report, Object Required is because oOL has not been set at all due to an error with the line above. If I take your example and allow errors, we'll see that it's complaining about a syntax error stemming from the call to GetObject. I believe you meant to use CreateObject?

Assuming that's the case, you'll have to run it again and see if it works. If not, and you get an error like "ActiveX component can't create object" it means you don't have the necessary DLL installed for Quantum SysMod. You should look at the software's documentation to see about registering it. You can also reference the regsvr32 page.

Again, if you have any other development tools available to you that can load the required component such as, C# or even VB.Net, then you should really try using those instead. VBScript is a terrible language.

0
votes

A suggestion: comment this line and run the program again.

On Error Resume Next

This line is not allowing you to understand the error because the program will go ahead even though the error is raised.