• Welcome to Theos PowerBasic Museum 2017.

Early binding Excel example

Started by James C. Fuller, February 10, 2009, 12:20:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

James C. Fuller

José,
  I recently installed Microsoft Office Home and Student 2007 and was surprised
that most of the examples still didn't work as the controls were still not available??
Must be a limitation of the product?

Anyway the PB9.0 Excel examples do work but as noted they are late binding. Are there
examples here using early binding with Excel?

James




José Roca

 
The examples that come with the compiler use early binding. If you mean direct interface calls, can't be used with Excel.

James C. Fuller

From one of the Excel examples:

James



'==============================================================================
'
'  ExcelAp1.bas example for PowerBASIC for Windows
'  Copyright (c) 2002-2008 PowerBASIC, Inc.
'  All Rights Reserved.
'
'  Run a short demonstration of sending data to Excel, and controlling Excel
'  to display a chart, using the Dispatch Interface. We could of also used
'  the faster Direct Interface, but this is to demonstrate useage of the
'  OBJECT statements with IDBind (Dispatch) Interfaces. See the other COM
'  samples for examples of Direct Interfaces.
'
'  * Tested with Excel v9.00 (Office 2000) and v12.0 (Office 2007) and VBA
'    installed *
'
'==============================================================================


José Roca

#3
 
Ask Steve about his experiences trying to work with Excel using direct interface calls :)

You can not use Excel with direct interface calls. Only a few interfaces will work properly.

Excel is an oddity: it has a mix of dual interfaces, dispatch only interfaces and dispatchable interfaces, and the last ones can't be used with direct interface calls because none of the methods or properties return a reference to them.

For example, look at the declaration of the ActiveCell property:


Property Get ActiveCell <305> () As Range


It returns a reference to the Range dispatch interface, not to the IRange interface.