Excel 2013 64 bit: can not call DLL from worksheet (arguments are passed incorrectly) RRS feed

  • Question

  • I have 64 bit DLL with function like this

    double __stdcall f(double x);

    and XLA file like this

    Public Declare PtrSafe Function f Lib "x.dll" (ByVal x As Double) As Double

    I can call function f from worksheet by this terrible construction

    Public Function ws_f(ByVal x As Double) As Double
    ws_f = f(x)
    End Function

    But if I call function f directly from worksheet arguments are passed incorrectly. W H Y ?

    Excel xxxx 32 bit works fine

    Excel 2010 64 bit works fine also

    I read

    and cry - W H Y MS can not fix this?

    It is realy hard to wrap all function in DLL or migrate to XLL - simple tell me what can I do with DLL to fix this strange error - may be some compiller parameters magic?

    Friday, June 17, 2016 9:02 AM

All replies

  • Hi Александр Гусев,

    Since the issue is complex, I suggest you contacting Microsoft support to raise an incident so that our engineer could work closely with him to identify the root cause and resolve this issue as soon as possible.
    If the support engineer determines that the issue is the result of a bug the service request will be a no-charge case and you won't be charged. 

    Please visit the below link to see the various paid support options that are available to better meet your needs.

    Thanks for your understanding.

    • Proposed as answer by David_JunFeng Sunday, June 26, 2016 2:59 PM
    Tuesday, June 21, 2016 8:23 AM
  • I read your answer. I understand. I cry. I see that you do not want do anything.
    Tuesday, June 21, 2016 12:23 PM
  • This seems like a bug and your best chance is to follow David's suggestion and invoke Microsoft on this.

    Best regards, George

    Tuesday, June 21, 2016 12:53 PM
  • I would expect it to work better if you use the =REGISTER(...) approach to register your function with Excel, instead of relying on the VBA magic "Public Declare ..." approach.

    This page has lots of info and further pointers:

    You don't have to make the Macro sheet - just use the VBA Sub (it's called VbaReg()) near the bottom to call REGISTER. You still have to figure out the right arguments to pass to REGISTER - in your case the type code is probably "BB".


    Excel-DNA - Free and easy .NET for Excel

    Tuesday, June 21, 2016 7:19 PM