Some diagnostics to check valid Idispatch pointers
'07:01 23/03/2021
$filename "exceldemo.exe"
'uses RTL32
uses COM/COMutil
string filename
int i, j
filename = "C:\OxygenBasic\examples\COM\exceldemo.xls"
CreateInterfaceByName "Excel.Application" oExcelApp
ObjectByName(oExcelApp, "Workbooks", BSTR {}, oWorkBook)
print @oWorkBook
ObjectByName(oWorkBook, "Add", BSTR {0}, oExcelWorkbook)
print @oExcelWorkbook
ObjectByName(oExcelWorkbook, "Worksheets", BSTR {1}, oExcelSheet)
print @oExcelSheet
ObjectByName(oExcelSheet, "Range", BSTR {"G3"}, oRange)
print @oRange
LetByName(oRange, "Value", 123)
oRange.Release
ObjectByName(oExcelSheet, "Range", BSTR {"B1:B5"}, oRange)
CallByName(oRange, "BorderAround", BSTR {1, -4138, 3})
ObjectByName(oRange, "Interior", BSTR {1}, oInterior)
LetByName(oInterior, "ColorIndex", 38)
LetByName(oInterior, "Pattern", "xlSolid")
oRange.Release
oInterior.Release
for i = 0 to 10
for j = 0 to 10
ObjectByName(oExcelSheet, "Cells", BSTR {i, j}, oCell)
LetByName(oCell, "Value", "test-" + str(i) + "-" + str(j))
oCell.Release
next j
next i
CallByName(oExcelWorkbook, "SaveAs", BSTR {filename})
CmdByName(oExcelWorkbook, "Close")
CmdByName(oExcelApp, "Quit")
oExcelSheet.Release
oExcelWorkbook.Release
oWorkBook.Release
oExcelApp.Release
print "Speadsheet Created."