B
Barry
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
(e-mail address removed)
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
(e-mail address removed)