Can't create ActiveX object from JScript, "Automation server can't create object" RRS feed

  • Question

  • I've written an ActiveX component that supports automation that I'd like to use in a web page. However, when I put into my JScript:

    var obj = ActiveXObject("servername.typename")

    I get the error "Automation server can't create object." I have registered the class with regsvr32 on the machine on which I'm viewing the page. I have also marked the control in the registry as safe for scripting and safe for initialization. The problem occurs whether I open the page as a local file in Internet Explorer, of if I put it on my web site.

    I also wrote a short Visual Basic program to create the component using CreateObject("servername.typename"), and that works fine, so it seems like the component works okay; it's something about it being created in IE. I'm testing on IE 8 on Windows 7.

    Does anyone have any ideas on why I can't create my object? Thanks for any help.
    Friday, July 17, 2009 2:56 PM


  • var obj = ActiveXObject("servername.typename")
    Okay, it was a stupid JavaScript error. It should say:

    var obj = new ActiveXObject("servername.typename")

    Why that produces the particular error that I saw is an interesting question, but adding the "new" fixed it.
    • Marked as answer by Ben Coden Friday, July 17, 2009 6:51 PM
    Friday, July 17, 2009 6:51 PM