Board index » delphi » Excel Problem to obtain all Worbooks opened

Excel Problem to obtain all Worbooks opened


2007-05-16 08:32:29 PM
delphi252
Hello,
I would like to list all workbooks opened.
Here is my code:
XlApp: OleVariant ;
XlApp := GetActiveOleObject('Excel.Application');
For I:=1 To XlApp.WorkBooks.Count Do
ShowMessage(XlApp.WorkBooks[I].FullName) ;
When i launch 2 (or more) Workbooks and i execute this code,
the XlApp.WorkBooks.Count property is always = 1.
Solutions ?
Thanks
jm
 
 

Re:Excel Problem to obtain all Worbooks opened

Quote
Solutions ?
Worksheets not workbooks?
Oliver Townshend
 

Re:Excel Problem to obtain all Worbooks opened

Hello Oliver,
Thanks for your answer.
But WorkSheets (as a sheets collection) belong to a book.
Application.WorkSheets is equal to Application.ActivWorkBook.Sheets
WorkBooks[1].WorkSheets is equal to WorkBooks[1].Sheets
WorkSheets is a sheet container.
WorBooks is a book container.
Other solutions ?
Thanks
jm
"Oliver Townshend" <oliveratcodelegaldotcomdotau>a écrit dans le message de
Quote
>Solutions ?

Worksheets not workbooks?

Oliver Townshend