What's wrong with this PBWin9 code? I'm running this on Windows XP with Excel 12. The include file was created by using PowerBASIC COM Browser. The program consistently GPF's when getting to the following code line:
Am I doing something wrong or is something not functioning correctly?
If I run the same code on Windows Vista with Excel 8 and a properly updated include file, I get an error 99 (Object Error) on the following code line:
By the way, I'm specifically trying to use the direct interface.
Thanks,
Calvin
Code:
oExcelRange.FormulaR1C1(0) = vVnt
If I run the same code on Windows Vista with Excel 8 and a properly updated include file, I get an error 99 (Object Error) on the following code line:
Code:
oExcelApp.Visible(0) = 1
Code:
#Compile Exe #Dim All #Include ".\Excel_PB9.inc" Function PBMain () As Long Dim oExcelApp As Int__Application Dim oExcelWorkbook As Int__Workbook Dim oExcelRange As IRange Dim vVnt As Variant oExcelApp = NewCom $PROGID_Excel_Application If IsFalse IsObject(oExcelApp) Then MsgBox "Cannot get object: oExcelApp" Exit Function End If oExcelApp.Visible(0) = 1 oExcelWorkBook = oExcelApp.Workbooks.Add() If IsFalse IsObject(oExcelWorkbook) Or Err Then MsgBox("Excel could not open workbook.") GoTo Terminate End If oExcelRange = oExcelApp.ActiveCell If IsFalse IsObject(oExcelRange) Or Err Then MsgBox("Excel could not set range.") GoTo Terminate End If vVnt = "Sample Text" '----------------------------- MsgBox "Pause before setting text" 'Here's where the GPF happens. oExcelRange.FormulaR1C1(0) = vVnt MsgBox "Pause after setting text" '----------------------------- oExcelWorkbook.Close oExcelApp.Quit MsgBox "Finished" Terminate: Let oExcelRange = Nothing Let oExcelWorkbook = Nothing Let oExcelApp = Nothing End Function
Calvin
Comment