Is there a simple way to display the save as dialogue, allow the user to select a location and then save a copy of the active sheet as a csv to the location the user supplies without closing the original workbook?
I'm using the following code, however the original workbook gets automatically closed and the newly saved csv is left open....
Public Sub subSaveAsCSV()
Dim strFolderPath As String
Dim strFilePath As String
strFolderPath = Application.ActiveWorkbook.Path & "\"
strFilePath = Application.GetSaveAsFilename(strFolderPath, "CSV (Comma delimited) (*.csv), *.csv")
If strFilePath <> "False" Then
' Check if the file path already exists
If Not Dir(strFilePath) <> "" Then
' If it doesn't exist then save it
' Trap the error and ignore it
On Error Resume Next
If Err.Number = 1004 Then
On Error GoTo 0
Else ' User presses Save
.SaveAs Filename:=strFilePath, FileFormat:=xlCSV