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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save Individual Excel Worksheet to File

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
I'm working with VFP 9 and Excel 2000. I have the following code working to save an individual worksheet to a file. Is there a better method of doing this?
Code:
oWorkSheet = oWorkBook.WorkSheets(StaffWsName)
oNewBook = oExcel.WorkBooks.Add
oWorkSheet.Copy(,oNewBook.Worksheets(3)) && Copy sheet 1 after sheet 3
oExcel.DisplayAlerts = .F.
oNewBook.SaveAs ("C:\App\Temp\" + oWorkSheet.Name)
oNewBook.Close 
oExcel.DisplayAlerts = .T.

The following code seems to be a better approach, but it saved the entire workbook. Will this work with the newer versions of Excel.
Code:
oWorkSheet.SaveAs ("C:\App\Temp\" + oWorkSheet.Name)
Always open to suggestions and improvements.

Auguy
Northwest Ohio
 
faq 707-2482 in VBA forum addresses the same issue i think.
wjw

This old world keeps spinning round - It's a wonder tall trees ain't layin' down
 
Thanks. That code is slightly differennt than what I had tested. I will check it out.

Auguy
Northwest Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top