Board index » delphi » Excel 95 & 97 OLEAuto

Excel 95 & 97 OLEAuto

The following code starts up Excel, loads the sheet Order Print & then
activates for  insertion of data at cell represented by 'A' + i-54.

     sheet:=createoleobject('Excel.Sheet');
     sheet.Application.Workbooks.open('c:\meditrac
projects\Ainsworth\Order Print.xls');
     sheet.Application.worksheets('Sheet1').activate;
     sheet.Application.worksheets('sheet1').range('A' +
inttostr(i-54)).Value:=
          'Ainsworth Surgical Supplies';

This is fine for Excel 95 but for Excel 97 delphi reports 'member not
found' at line

     sheet.Application.worksheets('Sheet1').activate;

Help

Tim Bugg

 

Re:Excel 95 & 97 OLEAuto


Quote
Tim Bugg wrote:

> The following code starts up Excel, loads the sheet Order Print & then
> activates for  insertion of data at cell represented by 'A' + i-54.

>      sheet:=createoleobject('Excel.Sheet');
>      sheet.Application.Workbooks.open('c:\meditrac
> projects\Ainsworth\Order Print.xls');
>      sheet.Application.worksheets('Sheet1').activate;
>      sheet.Application.worksheets('sheet1').range('A' +
> inttostr(i-54)).Value:=
>           'Ainsworth Surgical Supplies';

> This is fine for Excel 95 but for Excel 97 delphi reports 'member not
> found' at line

>      sheet.Application.worksheets('Sheet1').activate;

> Help

> Tim Bugg

I could not deside this problem.
Try to use Application object instead of Sheet one:

Excel:=CreateOleObject('Excel.Application');

--
Vyacheslav Barulin
Russia,   Computing Centre SB RAS , Novosibirsk
Web-site :   http://labtech.sscc.ru/~slavb
e-mail   :   o...@kti.nsc.ru, sl...@labtech.sscc.ru

Re:Excel 95 & 97 OLEAuto


Try the following:
     sheet.Application.worksheets['Sheet1'].activate;

--David

Quote
Tim Bugg wrote in message <350fabb9.39489...@newshost.nwnet.co.uk>...
>The following code starts up Excel, loads the sheet Order Print & then
>activates for  insertion of data at cell represented by 'A' + i-54.

>     sheet:=createoleobject('Excel.Sheet');
>     sheet.Application.Workbooks.open('c:\meditrac
>projects\Ainsworth\Order Print.xls');
>     sheet.Application.worksheets('Sheet1').activate;
>     sheet.Application.worksheets('sheet1').range('A' +
>inttostr(i-54)).Value:=
>          'Ainsworth Surgical Supplies';

>This is fine for Excel 95 but for Excel 97 delphi reports 'member not
>found' at line

>     sheet.Application.worksheets('Sheet1').activate;

>Help

>Tim Bugg

Re:Excel 95 & 97 OLEAuto


In article <350fabb9.39489...@newshost.nwnet.co.uk>,
  t...@wwn.co.uk (Tim Bugg) wrote:

Quote

> The following code starts up Excel, loads the sheet Order Print & then
> activates for  insertion of data at cell represented by 'A' + i-54.

>      sheet:=createoleobject('Excel.Sheet');
>      sheet.Application.Workbooks.open('c:\meditrac
> projects\Ainsworth\Order Print.xls');
>      sheet.Application.worksheets('Sheet1').activate;
>      sheet.Application.worksheets('sheet1').range('A' +
> inttostr(i-54)).Value:=
>           'Ainsworth Surgical Supplies';

> This is fine for Excel 95 but for Excel 97 delphi reports 'member not
> found' at line

>      sheet.Application.worksheets('Sheet1').activate;

> Help

> Tim Bugg

Tim,

   Try sheet.Application.ActiveWorkbook.Worksheets('Sheet1').Activate.  I
don't think the Application has a worksheets collection.

Phil Coveney

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

Other Threads