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

Excel communication using COM

jvandeven
New Contributor I
599 Views
I have been using COM in a Fortran application to read and write data to Excel files for a couple of years now. The COM routines that I am using were originally generated using the Module Wizard in VS2008 and Intel Visual fortran 9. I am currently using VS2010 with Intel Visual Fortran XE 2011 on a 64 bit operating system, and am considering upgrading my application to x64. Unfortunately it appears that the COM routines are not recognised by the 64 bit compiler. Is there a simple way that I can address this issue, or is it being fixed at present? (I have read the thread followingthomas_boehme's related query in mid 2010).
Many thanks,
Justin.
0 Kudos
1 Solution
Steven_L_Intel1
Employee
599 Views
This is undoubtedly because you have not declared the variables RANGE and WORKSHEET properly, but it's an understandable error. These items are handles to COM objects and need to be the size of an address on the platform. If you simply declared them as INTEGER or INTEGER*4, you'd get this error.

Note that the problem is NOT that the rputines "aren't recognized" - they are. If they weren't recognized you'd get very different errors. In this case, the compiler is telling you that the datatypes of some arguments don't match the declared routine.

Since you have USEd KERNEL32, declare these variables to be:

INTEGER(HANDLE)

and that should do it for boh 32-bit and 64-bit.

View solution in original post

0 Kudos
4 Replies
Steven_L_Intel1
Employee
599 Views
Can you show us an example of how the COM routines are "not recognized"? If you'll look at the Excel sample provided with the product, you'll see that the same generated EXCEL module is used for both 32-bit and 64-bit targets. I am not aware of a problem in this area.
0 Kudos
jvandeven
New Contributor I
599 Views
I haven't looked at the examples provided with the product - are you referring to the "Autodice" routine?
I am referencing the following (additional) library directory:
"C:\Program Files (x86)\Intel\ComposerXE-2011\mkl\lib\ia32"
I am referencing the following modules:
USE IFCOM
USE IFCOMTY
USE IFAUTO
USE KERNEL32
I am using commands such as:
worksheet = $Workbook_GetActiveSheet(workbook, status)
outSheet_temp = $Application_GetName(worksheet, status)
status = AUTOSETPROPERTY (range, "VALUE", xArr(jj,:), VT_R8)
and obtaining errors such as:
Warning 54 warning #6075: The data type of the actual argument does not match the definition. [RANGE] C:\NIESR\Prog_lab\nibax\DRAFT MODELS\30 - 23 Jun 2011\FORTRAN\6_analyses.F90 2824
Error 55 error #6284: There is no matching specific function for this generic function reference. [AUTOSETPROPERTY] C:\NIESR\Prog_lab\nibax\DRAFT MODELS\30 - 23 Jun 2011\FORTRAN\6_analyses.F90 2825
Warning 56 warning #6075: The data type of the actual argument does not match the definition. [WORKSHEET] C:\NIESR\Prog_lab\nibax\DRAFT MODELS\30 - 23 Jun 2011\FORTRAN\6_analyses.F90 2834

My apologies if I am making an obvious error - there seem to me to be a number of candidates for the errors that I am obtaining that are referenced above (theKERNEL32 library, and themkl\lib\ia32 library directory). Unfortunately, my green-belt status is unlikely to do an injustice to my technical knowledge in relation to fortran programming...
Many thanks Steve,
Justin.
0 Kudos
Steven_L_Intel1
Employee
600 Views
This is undoubtedly because you have not declared the variables RANGE and WORKSHEET properly, but it's an understandable error. These items are handles to COM objects and need to be the size of an address on the platform. If you simply declared them as INTEGER or INTEGER*4, you'd get this error.

Note that the problem is NOT that the rputines "aren't recognized" - they are. If they weren't recognized you'd get very different errors. In this case, the compiler is telling you that the datatypes of some arguments don't match the declared routine.

Since you have USEd KERNEL32, declare these variables to be:

INTEGER(HANDLE)

and that should do it for boh 32-bit and 64-bit.
0 Kudos
jvandeven
New Contributor I
599 Views
Many thanks Steve - 64 bit version compiled and up and running!
Justin.
0 Kudos
Reply