BCX COM Interface

BCX_COM_ERROR function

Purpose: BCX_COM_ERROR returns status of the the COM error indicator.

To get more information of error, call BCX_GET_COM_ERROR_DESC or BCX_GET_COM_ERROR_CODE.


 Syntax:

 RetBool = BCX_COM_ERROR 

 Parameters:

  • None.

 Return Value:

  • RetBool is the boolean TRUE or FALSE status of the COM error indicator. If a COM error occurs, TRUE is returned. If there is no error FALSE is returned.

BCX_GET_COM_SUCCESS function

Purpose: BCX_GET_COM_SUCCESS is opposite of BCX_COM_ERROR function. If a COM error does not occur, TRUE is returned. If there is an error, FALSE is returned.

To get more information of error, call BCX_GET_COM_ERROR_DESC or BCX_GET_COM_ERROR_CODE.


 Syntax:

 RetBool = BCX_GET_COM_SUCCESS 

 Parameters:

  • None.

 Return Value:

  • RetBool is the boolean TRUE or FALSE status of the COM error indicator. If a COM error does not occur, TRUE is returned. If there is an error, FALSE is returned.

Example:


 CLS
 
 DIM app AS OBJECT
 app = CREATEOBJECT("Excel.Application")
 
 IF BCX_COM_ERROR THEN
 PRINT BCX_GET_COM_ERROR_DESC$
 END
 END IF
  
 app.visible = true
 
 Sleep(2000) ' Excel will be visible for 2 sec, and than it will close.
 
 app.activeworkbook.saved = true ' don't prompt to save workbook
 
 app.quit
 
 SET app = NOTHING ' remember to call Set xxx = Nothing to release resources used by COM object!!!
 
 
 KEYPRESS

BCX_GET_COM_STATUS function

Purpose: BCX_GET_COM_STATUS will return TRUE if an OBJECT is in a transaction and FALSE if it is not in a transaction. This is a useful function for debugging applications using COM.


 Syntax:

  RetBool = BCX_GET_COM_STATUS(&ObjPtr) 

 Parameters:

  • &ObjPtr is a pointer to a COM OBJECT.

 Return Value:

  • RetBool is the Boolean TRUE or FALSE status of the transaction state of the COM OBJECT.

Example:

 
 BCX_SHOW_COM_ERRORS(TRUE)
 
 DIM RetBool 
 DIM app AS Object
 SET app = CREATEOBJECT("Excel.Application")
  
 app.workbooks.add
 app.visible = true
 app.ActiveSheet.Cells(3,1).Value="Hello"
 app.ActiveSheet.Cells(4,1).Value="From BCX"
 app.ActiveSheet.Cells(5,1).Value="Console program!"
  
 RetBool = BCX_GET_COM_STATUS(&app)
 IF RetBool <> 0 THEN
   MSGBOX "Loaded app.ActiveSheet.Cells"
 END IF
 
 DIM temp_var$ 
  
 temp_var$ = app.ActiveSheet.Cells(3,1).Value
 MSGBOX temp_var$, "value of cell(3,1)", 4096
  
 RetBool = BCX_GET_COM_STATUS(&app)
 IF RetBool <> 0 THEN
   MSGBOX "Displayed value of cell(3,1)"
 END IF
 
 MSGBOX "BCX COM Example!" & CRLF$ _
 & "Using Office automation to manipulate Excel." & CRLF$ _
 & "Program will close Excel in 1 second.","finished!", 4096
 
 SLEEP(1000)
 
 app.activeworkbook.saved = true
 app.quit
 SET app = Nothing
 
 RetBool = BCX_GET_COM_STATUS(&app)
 IF RetBool = 0 THEN
   MSGBOX "Nothing means Nothing"
 END IF

For more examples of the BCX COM functions see the COM folder in the Files section of the BCX Group on Yahoo.

Related topics: Object data type definition | CREATEOBJECT | List of all COM Interface Functions