- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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