Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP7: Worksheet names 1

Status
Not open for further replies.

cj001

Programmer
Oct 3, 2001
145
US
Hello!

Is there a way to retrieve the names of the worksheets in an EXCEL file?


CJ
 
cj001

Code:
o=CREATEOBJECT("excel.application")
mywb=o.Workbooks.Add() && Change this if its an existing one
mySheet=mywb.ActiveSheet
?mySheet.Name

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I am not sure if Mike's reply completely answered your question, but there is a forum:

"VBA Visual Basic for Applications (Microsoft)"

and they will assist with the VBA / Excel type of questions. Then use Mike's code to connect to Excel and manipulate it based on the suggestions received from the other group.



Jim Osieczonek
Delta Business Group, LLC
 
cj0001

After jimoo posted I released the code I suggested might not be complete, try this:
Code:
o=CREATEOBJECT("excel.application")
mywb=o.Workbooks.Add() && Change this if its an existing one
nCount = mywb.Sheets.Count
FOR i = 1 TO nCount
  ?mywb.sheets(i).name
ENDFOR


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
THANKS Jim Osieczonek and Mike Gagnon. That does what I'm looking for.

How do I quit the process?

When I have exited VFP I notice that EXCEL is still running in the PROCESS list which is tying up Excel.


CJ
 
Try:

o=CREATEOBJECT("excel.application")
mywb=o.Workbooks.Add() && Change this if its an existing one
nCount = mywb.Sheets.Count
FOR i = 1 TO nCount
?mywb.sheets(i).name
ENDFOR
o.quit
o=.null.




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
GREAT!!! Thanks again, Mike Gagnon.


:)
 
Mike,

For always showing members how simple and useful Microsoft Automation can be. Your 500th star. Now let's get to work! [bigsmile]

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
SlightHaze

For always showing members how simple and useful Microsoft Automation can be. Your 500th star. Now let's get to work!

Thank you for the star! Wow 500! Now I may just retire ;-).


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
uh....Mike,
retire ?
pfff...
I hope you remain here for at least another 500 stars....
-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top