none
Problems porting Excel interface C project to VS13/Excel13 RRS feed

  • Question

  • I’m attempting to reactivate a project for interfacing C functions with Excel, that worked fine several years ago, under VS6.0, and with an earlier version of Excel. The platform now consists of VS-13 and Excel 2013. My XLCall32.lib version is also old.

    Essentials of the code follow. The C compiles without errors or warnings, and a DLL is created. But when I run the module in Excel, there is an error “Can’t find entry point Mulo() …”.

    In the original project I used a .DEF file to declare the function, I’ve also tried adding this to the project, but the problem remains.

    Any assistance appreciated. Thanks in advance.

    // ***** C *****

    __declspec(dllexport) double WINAPI Mulo();

    double WINAPI Mulo()

    {

           return 1.0;

    }

     

     

      *****  VBA  *****

    Declare Function Mulo Lib "C:\DLLs\DLLtest.DLL" () As Double

    Sub DoCalc()

        ActiveSheet.Activate

        i = Mulo()

    End Sub

     



    bv

    Friday, August 21, 2015 11:27 AM

Answers

  • Hi BruseVx,

    I am trying to reproduce this issue however failed. Here are the detailed steps for your reference:
    1. Create an dll project(CallDllFromVBA) via C++ in Visual Studio 2013

    2. Code in CallDllFromVBA.cpp:

    // CallDllFromVBA.cpp : Defines the exported functions for the DLL application.
    //
    
    #include "stdafx.h"
    
    double _stdcall square(double *x)
    {
    	return *x * *x;
    
    }
    
    
    

    3. Add def file(defFile.def)

    LIBRARY "square"
     EXPORTS
     squareForEXL = square 

    4. Include the def file in property like figure below:

    5. Call the function from VBA like code below:

     Private Declare PtrSafe Function squareForEXL Lib "D:\CallDllFromVBA.dll" (ByRef x As Double) As Double
     Sub test()
     
     Debug.Print squareForEXL(5)
     End Sub
    

    And here is the c++ project structure for your reference:

    To debug the DLL project, we can set the properties listed below:
    1. Configuration Properties->Debugging->Command->file location for Excel.exe

    2.  Configuration Properties->C/C++->Broswe Information->Enable Broswe Information->Yes (/FR)

    And if you still have the issue about developing C++ library, I suggest that you reopen a new thread in C++ forum.

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, August 24, 2015 7:48 AM
    Moderator