Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA calling VBS gives "ActiveX component cant create object"

Status
Not open for further replies.

hnng

Civil/Environmental
Joined
Aug 17, 2007
Messages
38
Hi folks,

I am a newbie in using VB family of languages. I wrote a .NET dll which creates a process (objProcess.Start()) in one function and returns the pid and then in second function I pass the pid and monitor it using objProcess.WaitForExit(). I exposed it to the COM and registered it using REGASM with /tlb and /Codebase option. Then wrote a small VB script as shown: Lets call is TEST.vbs

Code:
Set objProc = CreateObject("CreateANDMonitor.Class1")
pid = objProc.fncCreate("calc.exe")
objProc.fncMonitor(pid)
msgbox "process ended"
Set objProc = Nothing

I double click the TEST.vbs and it launches the calc adn when I close cals it pops up the message. Everything is good till now :thumb:

Now I want to call this script from and out look macro, so I created one in outlook
Code:
Public Sub main()
 Shell "wscript C:\.....\TEST.vbs"
End Sub

If I do this I get the following error
Code:
MSG: ActiveX component cant create object: "CreateANDMonitor.Class1"
CODE: 800A01AD


Why the script is running fine by itself and not when called from an Outlook Macro.

Help will be highly appreciated.
HN
 
At a guess, if the DLL is not in the same directory as the script, it DLL needs to be registered first.

regsvr32 dllpath
 
Check with the geeks over at Tek-tips.com a sister to this site.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top