Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

excel vba <-> fortran

rmoortgat
New Contributor I
1,317 Views

I wrote a fortran program to calculate the moments and shear forces in a 2-span beam under moving forces.
I first tried with VBA but it took too long to run.
I want to pass the input from excel to fortran and get the results back.
I did some research but there is little to be found on the subject.
I tried with a simple routine i.e. adding two numbers an compiled the fortran source to a DDL. But after that I’m stuck. I found an example program on chat GPT but it doesnt work.
https://chatgpt.com/c/58715b3e-09a3-4d9b-9e5c-db20fe33d5675

Roger

0 Kudos
1 Solution
rmoortgat
New Contributor I
1,230 Views

 

I have Excell Office365. It's 64 bit.

I recompiled with "ifx Fcall.f90 /dll /libs:static /threads " and it runs now without a problem.

 

Roger

View solution in original post

5 Replies
Steve_Lionel
Honored Contributor III
1,256 Views

There is an example of Excel-Fortran in the samples bundle, under MixedLanguage. I would not trust anything ChatGPT tells you.

rmoortgat
New Contributor I
1,246 Views

Thank you.

The example is for win32. I recompiled the dll as x64 and added the PtrSafe attribute in VBA.

But now I get VBA Run-time error '53' File not found: c:\temp\Fcall.dll allthough the dll is there.

I suppose this is a very generic error and could actually mean anything.

 

Roger

 

0 Kudos
Steve_Lionel
Honored Contributor III
1,233 Views

You would need to be using 64-bit Excel to use a 64-bit DLL. It's been a while since I looked at this, but let me see if I can make it work for 64-bit.

rmoortgat
New Contributor I
1,231 Views

 

I have Excell Office365. It's 64 bit.

I recompiled with "ifx Fcall.f90 /dll /libs:static /threads " and it runs now without a problem.

 

Roger

Reply