From this How to browse for save directory?, I have used the following code to export Sheet1 to CSV file with browser file for saving :
Here the function that I used :
Sub ExportCSV()
Dim MyPath As String
Dim MyFileName As String
MyFileName = "Base_donnees" & "_" & Format(Date, "ddmmyyyy")
If Not Right(MyFileName, 4) = ".csv" Then MyFileName = MyFileName & ".csv"
Sheets("Sheet1").Copy
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = "" '<~~ The start folder path for the file picker.
If .Show <> -1 Then GoTo NextCode
MyPath = .SelectedItems(1) & "\"
End With
NextCode:
With ActiveWorkbook
.SaveAs Filename:=MyPath & MyFileName, FileFormat:=xlCSV, CreateBackup:=False
.Close False
End With
End Sub
And when I push on "Export to CSV" button, I get the following error:
and the debug window shows:
As you can see, I get a:
Runtime error '438' : Object doesn't support this property or method
Which method or property have I got to use? I am using Excel 2011 for MacOS.
VBA editor looks like this: