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 Solution
Build > Build Solution
Post 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 clean
build.bat release
build.bat debug
build.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 Events
Edit
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 Module1
File > Close
to close the editor.Excel
and save the file.Excel
is a 32-bit application, the DLL must also be 32-bit.