Board index » delphi » OLE Automation Controller (controlling Excel from Delphi 2.0)

OLE Automation Controller (controlling Excel from Delphi 2.0)

Hi,

I need to control Excel from Delphi 2.0. I use this code

var
   Excel: variant;
begin
  Excel = CreateOleObject('Excel.Application');

Now I need to open an existing Excel sheet. I've tried:

Excel.Workbook.Open('mysheet');
Excel.Workbooks.Open('mysheet');
Excel.Application.Workbook.Open('mysheet');
Excel.Application.Workbooks.Open('mysheet');

etc. etc.

Every time i get "Method xxxx not supported by OLE object"

Which mehod should I use, or better, how can i find out the list of
methods supported by a certain OLE Automation Server??

Thanks,
        Corrado

Corrado Labinaz        
Vicenza (Italy)
internet:  c...@gpnet.it

 

Re:OLE Automation Controller (controlling Excel from Delphi 2.0)


Corrado Labinaz <c...@gpnet.it> wrote

Quote
> Hi,

> I need to control Excel from Delphi 2.0. I use this code

> var
>    Excel: variant;
> begin
>   Excel = CreateOleObject('Excel.Application');

> Now I need to open an existing Excel sheet. I've tried:

> Excel.Workbook.Open('mysheet');
> Excel.Workbooks.Open('mysheet');
> Excel.Application.Workbook.Open('mysheet');
> Excel.Application.Workbooks.Open('mysheet');

> etc. etc.

> Every time i get "Method xxxx not supported by OLE object"

> Which mehod should I use, or better, how can i find out the list of
> methods supported by a certain OLE Automation Server??

> Thanks,
>    Corrado

> Corrado Labinaz        
> Vicenza (Italy)
> internet:  c...@gpnet.it

I think your problem is that Excel translates all Methods when using OLE.
You should have a file called something like crossref.xls, (Yes, they have
translated the filename too).
In that file you'll find a translation of every method.
If you would like to know more about what they do. Just look in your Excel
help-fil.

Stefan Jonsson
ste...@extrico.se

Re:OLE Automation Controller (controlling Excel from Delphi 2.0)


In article <32f46209.5220...@news.gpnet.it>, Corrado Labinaz
<c...@gpnet.it> writes

Quote
>Hi,

>I need to control Excel from Delphi 2.0. I use this code

>var
>   Excel: variant;
>begin
>  Excel = CreateOleObject('Excel.Application');

>Now I need to open an existing Excel sheet. I've tried:

>Excel.Workbook.Open('mysheet');
>Excel.Workbooks.Open('mysheet');
>Excel.Application.Workbook.Open('mysheet');
>Excel.Application.Workbooks.Open('mysheet');
>Every time i get "Method xxxx not supported by OLE object"

I've used the following to open a spreadsheet and then save it as a CSV
file.

Excel := CreateOleObject('Excel.Application.5');
Excel.Workbooks.Open(Filename:=FileIn);
Excel.ActiveWorkbook.SaveAs(Filename:=CSVFileName,FileFormat:=6 );
Excel.ActiveWorkbook.Close(SaveChanges := False);

The 'Excel.Application.5' I got from running regedit
The rest of the commands I got by recording a macro in Excel and then
looking at that.

I hope this helps.
--
Simon Riggs

Other Threads