Try .Sheets.Count
In Excel, use the VBA Object Browser and drill down to sheets. You should get the details there.
I know Excel defaults to 3 sheets when it opens a new workbook, but you are opening a old file.
If you are addressing a sheet by using the name Excel has assigned, be careful.
I have seen Excel change the 'Sheet 1' to 'Sheet 2' when I created a chart. All my data references for the chart were pointing to Sheet 1. I assigned Sheet 1 a name and referred the sheet name and everything worked fine.
>I use the following code to open an Excel Workbook from VFP:
>
>ExcelObj = CreateObject('Excel.Application')
>ExcelObj.Visible = .T.
>ExcelObj.Workbooks.Open("D:\TEST.XLS")
>
>Does anyone know of a way to return the number of WORKSHEETS in the open workbook? I can't seem to find an object property that tells me this.
>
>Thanks
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement