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

AutoDice example does not work

cobek69
Beginner
329 Views

Hi all,
some help regarding this issue would be appreciated.

I am using Windows 7, Excel 2010 andIntel Visual Fortran Composer XE 201112.0.3471.2008.
I can not getoriginal AutoDice example working as the function call Workbooks_Open fails.
(Note: I changed Excel version to 14and Excel could have been succesfully started)

In the CVF 6.6 i used the same function, but i had to change slightly the original codein following way
(note that only relevantfunction parameters are shown, as other do not play any role):

INTEGER(INT_PTR_KIND()) FUNCTION Workbooks_Open($OBJECT, Filename, ..., $STATUS)
!DEC$ ATTRIBUTES DLLEXPORT :: Workbooks_Open
IMPLICIT NONE
INTEGER(INT_PTR_KIND()), INTENT(IN) :: $OBJECT ! Object Pointer
!DEC$ ATTRIBUTES VALUE :: $OBJECT
CHARACTER($MAXPATH), INTENT(IN) :: Filename ! BSTR
...
INTEGER(handle), INTENT(OUT), OPTIONAL :: $STATUS ! Method status
!DEC$ ATTRIBUTES REFERENCE :: $STATUS

INTEGER(INT_PTR_KIND()), VOLATILE :: $RETURN
INTEGER(handle) $$STATUS
INTEGER(INT_PTR_KIND()) invokeargs
type(VARIANT) vBSTR
invokeargs = AUTOALLOCATEINVOKEARGS()
CALL AUTOADDARG(invokeargs, '$RETURN', $RETURN, AUTO_ARG_OUT, VT_DISPATCH)
call fstr2bstr(Filename,vBSTR)
call AUTOADDARG(invokeargs,'$ARG1',vBSTR,AUTO_ARG_IN)
$$STATUS = AUTOINVOKE($OBJECT, 1923, invokeargs)
...
IF (PRESENT($STATUS)) $STATUS = $$STATUS
Workbooks_Open = $RETURN
CALL AUTODEALLOCATEINVOKEARGS (invokeargs)
$$STATUS=VariantClear(vBSTR)
END FUNCTION Workbooks_Open

I wrote a functionfstr2bstr(fstr,bstr):
subroutine fstr2bstr(fstr,bstr)
implicit none
type
(VARIANT) bstr
character
(*) fstr
call
VariantInit(bstr)
bstr%VT=VT_BSTR
bstr%VU%PTR_VAL=ConvertStringToBSTR(trim
(fstr))
end subroutine

Everything worked finewith XP, Excel 2003 and CVF6.6. I tried to use same"trick" onnew system, after could not get AutoDice example running, but no way.
I guess that it might bea problem with passing the excel workbook name to Workbook_Open function. Has someone already expirienced the same thing andcan help?

0 Kudos
1 Reply
cobek69
Beginner
329 Views
I have just seen the post from aagaard July 19, 2010 and solved the problem. My local format settings were not set to English US and somehow this caused the problem.
0 Kudos
Reply