March 26th, 2008, 10:03 am
Hi gatechfe08,There is a nice article in codeproject.com.I have made a dll in C++ Borland with the help of the person who has written the article on codeproject.The function is to sum two integers and return the sum in a cell in excel.You need the Borland 5.5.1 compiler for this.The Code(sumtwoints.cpp)----------------------------------#define dllexport __declspec(dllexport)extern "C" {dllexport _stdcall int sum_two_integers (int first, int second) { return first + second; }}The Command line compile---------------------------------BCC32 -tWD -O2 sumtwoints.cppThe output will be a sumtwoints.dll. This should be copied into the same folder where your excel file sits.Now open VBE of Excel. Add this line in a VBA module.Public Declare Function sum_two_integers Lib "sumtwoints" (ByVal first As Long, ByVal second As Long) As LongGo to cell in workbook. and type sum_two_integers(1,2). You should be getting the results. Remember to use the latest compiler. google it.Regards