Board index » delphi » excel 97 - syntax problem - help please

excel 97 - syntax problem - help please

i am trying to close a specific excel file from an OLE session i have
running

i tried all the following but it crashes with member not found
  excelole.workbooks('test').close;
  excelole.workbooks('test.xls').close;
  excelole.workbooks(test1').close;
(this one because thats what excel shows in the header when the file is open
??)

i know the following does work but it closes all workbooks
  excelole.workbooks.close;

 

Re:excel 97 - syntax problem - help please


Hi Steve!
Use '[]' instead of '()' like this:

excelole.workbooks['test'].close;

Whenever you access an indexed property use brackets, parenthesis are used
only
for method calls.

Sergio

Re:excel 97 - syntax problem - help please


Hi steve -

try
    excelole.workbooks['test'].close;

You have to use delphi's  array notation, not VBA's.

good luck,
-- leon

Quote
Steve wrote:
> i am trying to close a specific excel file from an OLE session i have
> running

> i tried all the following but it crashes with member not found
>   excelole.workbooks('test').close;
>   excelole.workbooks('test.xls').close;
>   excelole.workbooks(test1').close;
> (this one because thats what excel shows in the header when the file is open
> ??)

> i know the following does work but it closes all workbooks
>   excelole.workbooks.close;

Other Threads