Runtime Error 49, Bad DLL calling convention

excel, vba

Solution

This error is probably occurring because of a compiler-bug. The easiest solution to this, would be to make a small code-change and recompile. What I usually do is,

1 -> Add a `Private Enum` type to the top of any module in the addin

Private Enum Something
    member = 1
End Enum

2 -> Compile the addin

3 -> Restart excel

4 -> Remove the code change made. It is no longer necessary.

Problem

Q. Excel keeps throwing the following error, whenever my addin is loaded (Runtime Error 49, Bad DLL calling convention) The dialog starts to pop up everytime with no indication of where the error is, despite having absolutely no external DLL references. OR Q. Excel crashes every time I save a particular line of code. How can this be fixed?

Original source