Michael,

You want to use strings to initialise a Range object.

var
  xlRange : Excel_TLB.Range;
begin
  //...

  ASHT := ER.OLEExcel.ActiveWorkbook.ActiveSheet;

  xlRange := ASHT.Range[ 'A1', 'H8'];

  // eg. set colour of cells in range ( 0 <= iColour <= 56)
  xlRange.Columns.Interior.ColorIndex := iColour;
end;

Which, I seem to recall, comes from the property:

  property Range[Cell1: OleVariant; Cell2: OleVariant]: Range  read
Get_Range;

on _Worksheet.

Hope this helps,
Good luck...
Kurt.



Michael Switzer wrote:
> 
> Hi all,
> 
> I'm trying to get Delphi 4 to create a chart in Excel.  Stop sniggering.
> 
> Does anyone know how to get an Excel 'Range' object to work?  The docs say
> it expects an argument of - in VB speak - ("A1:H8")  so that it looks like
> ...Range("A1:H8")...
> 
> So far my code does the following:
> 
> <snip>
> ER := TExcelReport.Create;  //  ER.OLEExcel is the OLE automation object for
> the Excel Application
> <snip>
> ASHT := ER.OLEExcel.ActiveWorkbook.ActiveSheet;
> ASHT.Range('A1');  // error
> <snip>
> 
> Variations on this error line (like below) don't work as far as I can see.
> ASHT.Range.Cells(1,1);
> ASHT.Range('"A1'");
> ASHT.Range(ASHT.Range.Cells(1,1), ASHT.Range.Cells(2,2)):
> 
> My aim is to get back a range object that I can then use to help create my
> chart.
> 
> Many thanks in advance.
> 
> Cheers,
> 
> Michael Switzer
> Jump Productions
> Phone  +64 7 838 3371
> Fax       +64 7 838 3372
> Email    [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz

-- 
_______________________________________________________________________
Kurt Wilkin                                     Phone: (+64 4) 473 1480
OO Developer                                      Fax: (+64 4) 473 1515
ACT Financial Systems,                              
Level 10, Dalmuir House, 114 The Terrace.                              
PO Box 10_278, Wellington.               email: [EMAIL PROTECTED]

***********************************************************************
This  communication  is confidential  to ACT  Financial  Systems  (Asia
Pacific)  and is intended for  use only by the  addressee.   The  views
and opinions  expressed in  this email  are the senders  own and do not
represent  the  views  and  opinions of  ACT  Financial  Systems  (Asia
Pacific).
***********************************************************************
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to