Runtime Error 49, Bad DLL calling convention

后端 未结 8 1707
闹比i
闹比i 2020-12-29 12:10

Q. Excel keeps throwing the following error, whenever my addin is loaded (Runtime Error 49, Bad DLL calling convention)

相关标签:
8条回答
  • 2020-12-29 12:34

    In my case this was "caused" by an excessive use of the continue character _ in a single if conditional

    I had already recompiled, checked all return codes, moved modules around ,restarted excel , restarted my computer, copied the code to a brand new Excel spread-sheet, I read this article and the bit about return codes made me think about how many returns can be in an if statement

    I had this

        If CompressIntoOneLineON(rg1, rgstart, rgend) or _
           CompressIntoOneLineOS(rg1, rgstart, rgend) or _
           CompressIntoOneLineOGN(rg1, rgstart, rgend) or _
           CompressIntoOneLineOGS(rg1, rgstart, rgend) or _
           CompressIntoOneLineGO(rg1, rgstart, rgend) Then
           <code>
        End If
    

    I was getting the error when the subroutine containing this code exited So I changed to this

    matched = True
    If CompressIntoOneLineON(rg1, rgstart, rgend) Then
    ElseIf CompressIntoOneLineOS(rg1, rgstart, rgend) Then
    ElseIf CompressIntoOneLineOGN(rg1, rgstart, rgend) Then
    ElseIf CompressIntoOneLineOGS(rg1, rgstart, rgend) Then
    ElseIf CompressIntoOneLineGO(rg1, rgstart, rgend) Then
    Else
      matched = False
    End If
    if matched then
      <code>
    

    and the error went away

    0 讨论(0)
  • 2020-12-29 12:49

    I had a similar issue, on my development PC it was working just fine. Funny thing was I had two separate calls to the same routine, one worked and the other didn't. On a production PC, kept getting the error. Tried renaming the routine, changing the parameters, parameter types to no avail.

    What worked for me was to move the failing calling routine into the same module as the called subroutine.

    The routine that was working previously was already in the same module.

    0 讨论(0)
提交回复
热议问题