I suggest to have a general function to open excel workbooks ( you may keep it in your libaray )
Code: Select all
function xlsBookOpen( ... ) // ( oExcel, cFile, < .. open params > )
local aParams := HB_AParams()
local n
local oExcel := aParams[ 1 ]
local oBook
ADel( aParams, 1, .t. )
for n := 2 to Len( aParams )
if aParams[ n ] == nil
aParams[ n ] := OleDefaultArg()
endif
next
oBook := HB_ExecFromArray( oExcel:WorkBooks, 'Open', aParams )
return oBook
Usage:
Code: Select all
oBook := xlsBookOpen( oExcel, cFile, , , , , '1111' )
If you are using a Class like TExcel, I suggest the following method
Code: Select all
method Open( ... ) class TExcel // ( cFile, < .. open params > )
local aParams := HB_AParams()
local n
local oBook
for n := 2 to Len( aParams )
if aParams[ n ] == nil
aParams[ n ] := OleDefaultArg()
endif
next
oBook := HB_ExecFromArray( ::oExcel:WorkBooks, 'Open', aParams )
return oBook
Note: OleDefaultArg() is a function from Win32Ole.Prg of XHarbour