LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Returning to Original Workbook After Saving Sheets

Greetings:

I have a VBA routine that saves each worksheet in the active workbook as a
..csv file. When finished, I want the original workbook to be active, with
its original name. In order to accomplish this, I must end the routine by
saving the workbook one more time, using its its original name. This is
undesirable as the user may wish to save the sneets but not save the whole
workbook.

Here is the code for the routine

#########
Sub saveallCSV()
Dim Fname As String
Dim OrigFname As String
Dim Fpath As String
Dim sht As Worksheet
OrigFname = ActiveWorkbook.Name
Fpath = ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each sht In Sheets
Fname = Fpath + "\" + sht.Name + ".csv"
sht.SaveAs Fname, FileFormat:=xlCSV
Next sht
Fname = Fpath + "\" + OrigFname
ActiveWorkbook.SaveAs Fname, FileFormat:=xlWorkbookNormal
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
#########

How can I eliminate the last save and still return to the original workbook?

Thanks in advance for your help.

Barry Carroll
PSC Scanning

--
(Cleverly disguised as a responsible adult)
---------
PSC Scanning, Inc. assumes no responsibility whatsoever for any statements
made by me. I''m entirely on my own.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop not returning to original workbook excelnut1954 Excel Programming 4 October 16th 06 08:43 PM
saving multiple sheets in a workbook Danimal82 Excel Discussion (Misc queries) 2 October 4th 05 05:34 PM
Copy tabs(sheets) from workbook without link to original source Rich Ulichny Excel Discussion (Misc queries) 3 August 25th 05 02:11 AM
Copy tabs(sheets) from workbook without link to original source Rich Ulichny Links and Linking in Excel 2 August 9th 05 03:26 PM
Returning to original workbook Jim Cone Excel Programming 0 July 23rd 04 11:03 AM


All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"