Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: James C. Fuller on February 10, 2009, 12:20:36 PM

Title: Early binding Excel example
Post by: James C. Fuller on February 10, 2009, 12:20:36 PM
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



Title: Re: Early binding Excel example
Post by: José Roca on February 10, 2009, 12:54:11 PM
 
The examples that come with the compiler use early binding. If you mean direct interface calls, can't be used with Excel.
Title: Re: Early binding Excel example
Post by: James C. Fuller on February 10, 2009, 01:36:42 PM
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 *
'
'==============================================================================

Title: Re: Early binding Excel example
Post by: José Roca on February 10, 2009, 03:40:33 PM
 
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.