Debra Pate's webpage on OLE automation shows you how to open and edit an excel 
spreadsheet.  Here is the link:

http://www.djpate.freeserve.co.uk/Automation.htm

I have some sample code that I have used.  

procedure TMainForm.BtnCreateWkshtClick(Sender: TObject);
Var
 Excel : Variant;
 ContinueFlag : Boolean;
 loop : Byte;
begin
X := 1;
ContinueFlag := True;
try
  Excel := CreateOleObject('Excel.Application');
   except
    ShowMessage('Excel could not initialize !');
    ContinueFlag := False;
   end;

  If ContinueFlag = True then
   Begin
   //Open Doc
   Excel.Workbooks.open('O:\Releasemanagement\Site logs\PilotList.Xls');
   Excel.Cells[1,1] := 'SiteID'; //Create Header row.
   Excel.Cells[1,2] := 'Domain';
   Excel.Cells[1,3] := 'State';
   Excel.Cells[1,4] := 'Contact';
   Excel.Cells[1,5] := 'Phone No.';
   Excel.Cells[1,6] := 'Installed?';
   Excel.Cells[1,7] := 'Ticket No.';
   Excel.Cells[1,8] := 'Description';
//..More code here
//...
   Try
    Excel.DisplayAlerts := False; // Clear all alerts
    for loop := 1 to Excel.Workbooks.Count do
      Excel.Workbooks[1].Close[SaveAll];
  except
    Showmessage('Cannot Save Spreadsheet');
  end
 Excel.Workbooks.Close;  
  end;
end;


Supposedly you can use macros to do your work and then convert them to VBA  
which will run inside the spreadsheet.

Hope this helps!

Tom Nesler
Live long!...   Code Well!...   and Prosper!...   V

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Stebbing
Sent: Saturday, August 11, 2007 6:19 PM
To: Borland's Delphi Discussion List
Subject: Re: About excel automation


At 11:43 PM 11/08/07, CRQ wrote:

>Hi,
>I use delphi 6. From my app, I need to open an excel workbook and edit some
>data. Not necesary to show the excel window.
>¿some example code?
>Thanks
>cr\

Hi There,

I use a component TscExcelExport which will allow you to do that.
http://www.scip.be

Cheers,
Chris.

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to