Results 1 to 2 of 2

Thread: VBA calling VBS gives "ActiveX component cant create object"

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    1

    VBA calling VBS gives "ActiveX component cant create object"

    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

    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

  2. #2
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: VBA calling VBS gives "ActiveX component cant create object"

    Quote Originally Posted by hnandan View Post
    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

    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
    maybe, because your dll isn't registed.
    gow regist manually?
    go start menu - run
    here, in textbox, write something like these: Regsvr32 "filepathandfilename"
    sample: Regsvr32 "C:\dll\dll.dll"
    i hope help you
    VB6 2D Sprite control

    To live is difficult, but we do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width