Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
EXCEL sheets.
Message
From
14/01/2002 15:36:56
Jonathan Cochran
Alion Science and Technology
Maryland, United States
 
 
To
14/01/2002 14:18:22
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00604451
Message ID:
00604554
Views:
27
I believe you had the correct statement in your original post to get the number of sheets.

Have you ever used the FOR EACH statement? It will loop through each object in a collection, in this case each sheet in the Sheets collection. You specify the object name you want to use after the FOR EACH statement, in this case lo_Sheet. In each iteration through the loop, lo_Sheet will be a reference to the current sheet.

Here are a couple different ways to do the same thing:
lo_Excel = CREATEOBJECT("Excel.Application")
lo_Excel.Workbooks.ADD()
FOR EACH lo_Sheet IN lo_Excel.Sheets
   ? lo_Sheet.NAME
ENDFOR
lo_Excel.ActiveWorkbook.CLOSE()
lo_Excel.QUIT()
lo_Excel = CREATEOBJECT("Excel.Application")
lo_Excel.Workbooks.ADD()
FOR ln_Loop = 1 TO lo_Excel.Sheets.Count
   lo_Sheet = lo_Excel.Sheets[ln_Loop]
   ? lo_Sheet.NAME
ENDFOR
lo_Excel.ActiveWorkbook.CLOSE()
lo_Excel.QUIT()
>In your reply to my excel question you had a for loop with lo_sheet. What is the actual propertie name after for each
>ex:
>FOR each sheet in lo_Excel.sheets?
>
>
>Also, do you know what propertie gets me the sheet count?
Previous
Reply
Map
View

Click here to load this message in the networking platform