I have fortran code that I would like to call as a subroutine in Excel VBA. I have followed numerous examples in the internet and on these forums without success. I have tried a simple example

subroutine quad_F(a,b,c,x,y)

!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, ALIAS:'quad_F' :: quad_F

double precision a,b,c,x,y

! solves the quadratic equation a*x^2+b*x+c=0 for x

x=(-b+sqrt(b**2-4*a*c))/(2*a)

y=(-b-sqrt(b**2-4*a*c))/(2*a)

z=1

return

end

compiled as a dynamic link library project dlltest.dll. I can link to it and call it successfully from another fortran program, but to do this I must link to the static library dlltest.lib in the calling program. There is no way to do this in Excel, so I think I am missing something. Here is the VBA I would like to use

Option Base 1

Declare Sub quad_F Lib "C:\Users\qz0wcd\Desktop\desktop\Li-ion literature\solid phase transport eqns\combined diffusion and stress\multi-species transport\dlltest\dlltest.dll" _

(ByRef a As Double, ByRef b As Double, ByRef c As Double, ByRef x As Double, ByRef y As Double)

Public Function qtest(a As Double, b As Double, c As Double)

Dim p(2) As Double

Call quad_F(a, b, c, x, y)

p(1) = x

p(2) = y

qtest = p

End Function

I have Windows 7 on a 64 bit machine and I am using Visual Studio 2008 version 9.021022. Any suggestions would be appreciated.