Re: Cannot call ActiveX component function from VBScript
- From: "mayayana" <mayaXXyana1a@xxxxxxxxxxxxxxxx>
- Date: Wed, 5 Sep 2007 10:49:19 -0400
I tried your code with another control, returning
a property. (I didn't have a function with no parameters
to test.) It worked with:
document.write(a.test)
but caused an error with:
document.write(a.test())
Another point, as Tom Lavedas said, is that an integer
type is not supported in VBS. You should return a
variant.
Neither of those seems to explain your error, though.
The code you have should work. Your error is indicating
that the function name is not in the component's type
library. Two thoughts on that, which may or may not
help:
1) Check your component in an object browser to make
sure you have a function named "test".
2) I've noticed that sometimes using RegSvr the
HKCR\Typelib key does not get updated and can cause
the error you're describing. It seems to happen when
a component is recompiled without changing the GUIDs.
(I don't know why. I suspect it's because the version
number doesn't get changed in the HKCR\Typelib subkeys.
But that's just a guess.)
So if you registered the component before you added
"test" and then re-registered it, that could explain the
problem. In that case you'd probably need to go in and fix
it by hand or recompile with new GUIDs.
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>
.
- References:
- Cannot call ActiveX component function from VBScript
- From: merdza
- Cannot call ActiveX component function from VBScript
- Prev by Date: Re: Cannot call ActiveX component function from VBScript
- Next by Date: Help needed: Very odd VB Script behavior
- Previous by thread: Re: Cannot call ActiveX component function from VBScript
- Next by thread: Re: Cannot call ActiveX component function from VBScript
- Index(es):
Relevant Pages
|