Home » excel » C++ 64-bit Excel add-in (XLL) is not loading correctly in 64-bit Excel

C++ 64-bit Excel add-in (XLL) is not loading correctly in 64-bit Excel

Posted by: admin April 23, 2020 Leave a comment

Questions:

I have a piece of C++ code, which creates a XLL (Excel add-in). It can be successfully loaded by Excel, and works perfectly.

Then, I switched to 64-bit Excel, and the code stopped working. So I have recompiled the code in Visual Studio using x64 platform settings. The compilation went error free.

Now when I try to load it in 64-bit Excel, Excel does not recognize the file extension:

enter image description here

It complains showing “The file format and extension of ‘MyAddin.xll’ don’t match.”, and gives me the follwoing options to continue: yes, no, or cancel.

If I ignore the message and press yes, then the add-in crashes, and I get the error:

This program cannot be run in DOS mode.

Since the add-in compiles correctly, I am not sure how to troubleshoot this error. My question is: Can anyone please give me any pointers as to how to overcome the problem?

My requirements are:

  1. 64-bit Excel must recognize my XLL as valid add-in (the first error message has to go away)

  2. What means the second error?

How to&Answers:

That message typically means the runtime linker can’t find a dll. Use depends.exe (64-bit) from sysinternals to find out which. You can ignore xlcall32.dll and ieshims.dll warnings.

Answer:

You use the 32 bit version of Excel to open the 64 bit plug-in, and you will report errors that can only be opened under DOS. You need to install a 64 bit (normally unable to install 32 bit and 64 bit) office to open the 64 bit plug-in!

Answer:

As mentioned by Keith, this error is likely because some .dll dependency is not being found. One specific problem that can arise is if your .xll is calling another .dll which lives in the same directory. When Excel starts up and loads the .xll it will search its working directory and be unable to find the .dll.

One way around this is to add the .dll’s directory to your Path.