- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello , i was trying to pass 2 arrays from fortran to vba ,i get passing 1 or 2 arrays , but when i try to pass 3 or more , Excel Crashes .
FOR 1 ARRAY 1 Dimension i didnt have problems
this is the code:
:::::::::::::::::::::::::::::::::::::::::::::::::::::: 1 ARRAY 1 DIMENSION ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FORTRAN SIDE:
SUBROUTINE INOUTA (FIV)
!DEC$ ATTRIBUTES DLLEXPORT,stdcall,reference,ALIAS:'INOUTA' :: INOUTA
Real, Dimension(20,1) :: FIV
DO 1 I=1,20
FIV(I,1)=I*2
1 CONTINUE
RETURN
END
VBA SIDE:
Public Declare PtrSafe Sub ABSUB Lib "ABSINOUT.dll" Alias "INOUTA" (outarray As Single)
Public Function FABS() As Variant
ABSactualWorkpath = ThisWorkbook.Path
ChDir ABSactualWorkpath
Dim ALEX(1 To 20, 1 To 1) As Single
Call ABSUB(ALEX(1, 1))
FABS = ALEX
End Function
:::::::::::::::::::::::::::::::::::::::::::: 2 ARRAYS 1 DIMENSION ::::::::::::::::::::::::::::::::::::::::::::::::::::
Fortran side:
SUBROUTINE INOUTA (FIV,POX)
!DEC$ ATTRIBUTES DLLEXPORT,reference,stdcall,ALIAS:'INOUTA' :: INOUTA
Real, Dimension(20,1),intent(INOUT) :: FIV,POX
DO 1 I=1,20
FIV(I,1)=I*1
1 CONTINUE
DO 2 I=1,20
POX(I,1)=I*2
2 CONTINUE
RETURN
END SUBROUTINE INOUTA
vba side:
Public Declare PtrSafe Sub ABSUB Lib "ABSINOUT.dll" Alias "INOUTA" (ByRef outarray As Single, ByRef outarry As Single)
Public Function FABS() As Variant
ABSactualWorkpath = ThisWorkbook.Path
ChDir ABSactualWorkpath
Dim ALEX(1 To 20, 1 To 1) As Single
Dim ALEXX(1 To 20, 1 To 1) As Single
Call ABSUB(ALEX(1, 1), ALEXX(1, 1))
FABS = ALEX
End Function
but whwn i try to pass 3 arrays excel crashes:
this is the code i wrote for 3 arrays
::::::::::::::::::::::::::::::::::::::::::::: 3 ARRAYS 1 DIMENSION ::::::::::::::::::::::::::::::::::::::::::::::::::::
Fortran:
SUBROUTINE INOUTA (FIV,POX,TETP)
!DEC$ ATTRIBUTES DLLEXPORT,reference,stdcall,ALIAS:'INOUTA' :: INOUTA
Real, Dimension(20,1),intent(INOUT) :: FIV,POX,TETP
DO 1 I=1,20
FIV(I,1)=I*1
1 CONTINUE
DO 2 I=1,20
POX(I,1)=I*2
2 CONTINUE
DO 3 I=1,20
TETP(I,1)=I*3
3 CONTINUE
RETURN
END SUBROUTINE INOUTA
VBA SIDE:
Public Declare PtrSafe Sub ABSUB Lib "ABSINOUT.dll" Alias "INOUTA" (ByRef outarray As Single, ByRef outarry As Single, ByRef outay As Single)
Public Function FABS() As Variant
ABSactualWorkpath = ThisWorkbook.Path
ChDir ABSactualWorkpath
Dim ALEX(1 To 20, 1 To 1) As Single
Dim ALEXX(1 To 20, 1 To 1) As Single
Dim ALEXXX(1 To 20, 1 To 1) As Single
Call ABSUB(ALEX(1, 1), ALEXX(1, 1), ALEXXX(1, 1))
FABS = ALEX
End Function
did you know why is this happening? i annex both examples , you need to use 64 bits excel to run it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UPDATE#6 ... i find no matters if you activate the references , just activate one of them , and this repair the file.... i dont know why but i think its only refreshing the references
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UPDATE1: I open my file in another computer, and i was able to get 2 arrays,
UPDATE2: i update my EXCEL 365 to the version 2207 Build 16.0.15427.20182 64-bits and it helps for the 2 arrays error but i still not able to run 3 or more....:/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UPDATE#3: I ADDED THIS REFERENCES IN VBA EXCEL REFERENCES TABLE...suprisely the code now work for 3 arrays!, going to try for 5 arrays to see if that helps!
I ANNEX THE REFERENCES CODES (i added these files in this reply), added to your reference code in visual basic in excel and select the VFPROj.dll and acept it magically it start working! , Also i copy the file to my another computer and works too =,D!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UPDATE #4 , trying to pass 4 arrays breaks excels again......the solution was dissabling the "Intel Fortran project Extensibility 13.0 type library" and then its start working for 4 arrays......
also i activate the Intel Fortran project Extensibility 18.0 type library and excel keep working well...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UPDATE#5 I try with 6 arrays and stop working... i desactivate the Intel Fortran project Extensibility 18.0 type library and then ...solved...weird but now it can hanndle 6 arrays without problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UPDATE#6 ... i find no matters if you activate the references , just activate one of them , and this repair the file.... i dont know why but i think its only refreshing the references
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let us know when you get to 128 arrays.
Doc (not an Intel employee or contractor)
[Maybe Windows 12 will be better]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry i was trying to be detailed because this cost me lot of time , i hope someday one person have the same problem and this post help him. I notice for 3 or more arrays you need to able that reference, but after that you need to Refresh your refereces. that only that.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page