J
John V
Here is my macro, pulled from elsewhere in this discussion group:
Sub saveascsv()
Dim SaveName
SaveName = ThisWorkbook.Path & "\CSV Output.csv"
Worksheets("Summary").Activate
Worksheets.Copy
Workbooks(Workbooks.Count).Activate
Workbooks(Workbooks.Count).SaveAs SaveName, xlCSV,
ConflictResolution:=xlLocalSessionChanges
Workbooks(Workbooks.Count).Close SaveChanges:=False
End Sub
My questions:
1. How do I "trap" the error whenever a prior version of "CSV Output" is
open? I'm thinking of a user msg such as "Please close CSV Ouput and try
again" with a Retry button.
2. How do I avoid the user being asked if s/he wants to overwrite an
existing version of the file? In this particular application, it is never
wrong to do so. The above code doesn't work.
Many thanks.
Sub saveascsv()
Dim SaveName
SaveName = ThisWorkbook.Path & "\CSV Output.csv"
Worksheets("Summary").Activate
Worksheets.Copy
Workbooks(Workbooks.Count).Activate
Workbooks(Workbooks.Count).SaveAs SaveName, xlCSV,
ConflictResolution:=xlLocalSessionChanges
Workbooks(Workbooks.Count).Close SaveChanges:=False
End Sub
My questions:
1. How do I "trap" the error whenever a prior version of "CSV Output" is
open? I'm thinking of a user msg such as "Please close CSV Ouput and try
again" with a Retry button.
2. How do I avoid the user being asked if s/he wants to overwrite an
existing version of the file? In this particular application, it is never
wrong to do so. The above code doesn't work.
Many thanks.