Re: Cannot call ActiveX component function from VBScript

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




<merdza@xxxxxxxxx> wrote in message
news:1188981002.879009.310930@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am trying to call ActiveX function which resides on a client
computer from vbscript or javascript. I developed a simple Visual C++
2005 ActiveX component (ocx file) with one exported method which
returns int value. When I try to call this method from VB, everything
works fine and I get the value that method should return.

The ActiveX component was registered on the client computer with
regsvr32. I tried in two ways to call the ocx method from javascript:
- with new ActiveXObject("progID"), where the progID was found in the
registry,
- with <object classid="clsid:xxxxxxx" id="xx">, and classid was also
found in the registry.

VBscript makes the object, but cannot call the ocx method. An error
"Object doesn't support this property or method" appears on the web
page.

At Internet Explorer options I enabled all activex objects both in
Internet and intranet zone.

I looked for some kind of solution everywhere, but didn't succeed. I
am blocked at two lines of code for a week. The code of html page with
vbscript follows. Thanks for any kind of help.

<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT language="vbscript">
Sub callTest
document.write(a.test())
End Sub
</SCRIPT>
</HEAD>
<BODY>
<OBJECT id="a" classid="CLSID:A2733628-A334-4207-83F1-F00198758EFF"
name="a" ></OBJECT>
<INPUT TYPE=button value="Test" onClick="callTest">
</BODY>
</HTML>


I've compiled ocx ActiveX components in VB with public functions that return
integers (integer, long, boolean, string, and variant) and they work fine
when called from VBScript. Are you sure the method you call was declared
Public? Are methods Private by default?

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


.


Quantcast