VBA CreateObject() Can’t create ActiveX component on 64Bit Windows

If you are running on a 64bit windows 7 system and have a VBA script that creates a COM/ActiveX/OLE component which fails with an error message like:

 

‘ActiveX component can’t create object’

 

Even though you know the component is registered and that you are using the correct progId etc, then it may be failing because the COM component in question is 32 bit and by default Windows7 runs the 64bit scripting engine.

 

If this is the case then you can get around the problem by explicitly using the 32 bit scripting environment which is most likely located here:

 

C:\Windows\SysWOW64\cscript.exe

 

So to run example.vbs in the 32bit environment use the following:

 

C:\Windows\SysWOW64\cscript.exe example.vbs

 

Hopefully you 32bit component will now load… mine did ;)

 
3 replies
  1. Roger Vincent
    Roger Vincent says:

    I’m having the exact problem you addressed, but how do I have MS Access tell Win 7 I want my VBA code run in 32-bit mode?

    BTW, I realize your probably not a VBA programmer, but might be able to point me in the rigth direction…

    Reply
  2. Roger Vincent
    Roger Vincent says:

    Sorry, here’s my exact code and I’m 99.9% it’s the problem you mentioned because the script works on my 32-bit Win 7 machine and my 32-bit Win XP machine with no problems.

    My purpose is that when users first install my Access runtime application, I want to see if they have Outlook installed. Based on what’s detected, a flag is set in a setup table.

    Dim obj as Object

    On Error Resume Next

    Set obj = CreateObject(“Outlook.Application”)

    If err.number = 0 then

    Else

    ENd if

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *