1
votes

I am trying to create a simple VB6 ActiveX exe and call it from Excel.

In VB6 I create an ActiveX DLL project called BigTrev, using all the default settings.

I create a MultiUse class called Trev with a single method containing no code

Public Sub HelloWorld() 
End Sub

I make a DLL and register it from the command line (VB6 also registers it for me but I did it using cmd as well anyway).

Then it Excel I create a reference to my DLL in a new workbook. It clearly has been registered because the Intellisense knows about Trev and HelloWorld.

Sub cats()

    Dim derek As BigTrev.Trev
    Set derek = New BigTrev.Trev
    derek.HelloWorld

End Sub

It compiles in Excel, when I step through it it fails in the second line, the Set one. Error message is "ActiveX component can't create object".

Why? I have done this or similar loads of times many years ago when VB6 was used widely, I am using Windows 7 now and I am an admin on my box.

1
Fails how/with what error?Alex K.
Sorry added to question, ActiveX component can't create objectRob Sedgwick
Native 64-bit apps cannot load 32-bit binaries. See here.Bond
By ActiveX controls, they mean DLLs or OCXs that would get loaded into Excel's 64-bit process space. An "ActiveX Server" (EXE) should work fine as it runs in its own process space.Bond
It's just "ActiveX EXE" and pretty easy to spot.Bob77

1 Answers

0
votes

I would suggest registering the DLL (or EXE if that's the direction you've chosen) with the relevant regsvr32.exe. In this case, where you're registering a 32bit DLL for use in 64bit environment, use the one hiding out in c:\windows\syswow64.

Sadly, I don't have Excel (shock, horror) and the spreadsheet I do have (LibreOffice) is 32bit.