简体   繁体   中英

Activex component can't create object:'xyz'

I have written the following piece of VB script which opens an existing aplication xyz from the path I specfied. The application (a custom windows application) opens succesfully. (I would like to use the automation interface of this application in my vb script.) for that I call CreateObject .

But, then I also get the error Activex component can't create object: 'xyz' for the line Set xyzObj = CreateObject("xyz") . The error is from this line, since if I remove this line there is no error.

Dim objShell 

Set objShell = CreateObject( "WScript.Shell" ) 
objShell.Exec("C:\abc\def\xyz.exe") 

Set xyzObj = CreateObject("xyz")

Set objShell = Nothing 

You can't use CreateObject like that with a external program, started in your script or otherwise. CreateObject loads a COM-object that is registered on your pc. Google on vbscript and COM objects and you'll find plenty of info like at http://technet.microsoft.com/en-us/library/ee156598.aspx . If you want to interact with a started program you could use the sendkeys method or better use the autoit com object , see http://www.autoitscript.com/autoit3/docs/intro/ComRef.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM