Re: Cannot call ActiveX component function from VBScript

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




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>



.



Relevant Pages

  • Re: Cannot instantiate .NET Class Library
    ... The ProgId was set to MyOrg.web.publications.Test and not testInterop.Test! ... > Have a look in the registry and find out what the InprocServer32 key looks ... ASP and vbscript are creating the object via its progid - is ... > problem is mscoree doesn't know where your class is so it tries to load ...
    (microsoft.public.dotnet.framework)
  • Re: Modify reg from Batch
    ... Using RegWrite method of VBScript may be your best bet. ... While my forte is ... the registry Torgeir's forte is VBScript so have a look at some of these for ... Microsoft MVP [Windows] ...
    (microsoft.public.win2000.registry)
  • GetStringValue silently fails
    ... I have a VBScript that uses GetStringValue to read two ... I restart the WMI service. ... I have only seen this problem with some registry values of type REG_SZ ...
    (microsoft.public.win32.programmer.wmi)
  • GetStringValue silently fails
    ... I have a VBScript that uses GetStringValue to read two ... I restart the WMI service. ... I have only seen this problem with some registry values of type REG_SZ ...
    (microsoft.public.scripting.vbscript)
  • ActiveX need help
    ... I have a problem with my ActiveX component, in my code, I download the ... ' If file exist it continues to modify registry setting ... Dim oShell ... Dim folder As String ...
    (microsoft.public.excel.programming)