This demonstrates calling a Fortran DLL from an Excel macro. The
provided xltest.xls spreadsheet (located in the .\src directory)
defines a macro that calls the FortranCall function when the button is
pushed.
This sample requires the 32bit version of Microsoft Excel* as it is not currently supported with 64bit Excel
.sln fileBuild > Clean SolutionBuild > Build SolutionPost build event copies the FCALL.dll from the build directory to C:\TEMP.\src\xltest.xls spreadsheet by double-clicking on it, enabling macros, then click the button.build.bat cleanbuild.bat releasebuild.bat debugbuild.bat run FCALL.dll to the C:\TEMP folder and copies file .\src\xltest.xls to current ".\" first, and then opens the .\xltest.xls
Because Excel requires an explicit path to the DLL, this has been set as
C:\TEMP\FCALL.dll. If you need to change this, do the following:
Fcall project in Visual Studio, and select Properties.Build Events, then Post-Build EventsEdit the Command Line to specify the new destination and click OK.xltest.xls. Click Enable Macros when prompted, and then
No to open the file for writing.
ALT-F11 to open the Visual Basic editor.+ next to "Modules" and then double-click on Module1File > Close to close the editor.Excel and save the file.Excel is a 32-bit application, the DLL must also be 32-bit.