0

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:

Error image

and the debug window shows:

Debug window

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:

VBA editor browse

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    This post my help:[Application.Filedialog support in Mac excel 2011](https://stackoverflow.com/questions/34960873/application-filedialog-support-in-mac-excel-2011) –  May 22 '18 at 04:36
  • Here is how to select folders with Mac VBA: https://www.rondebruin.nl/mac/mac017.htm – Ryszard Jędraszyk May 22 '18 at 05:39
  • select folder on Mac , refer to [this](https://msdn.microsoft.com/ko-kr/library/office/hh710200(v=office.14).aspx) – Dy.Lee May 22 '18 at 05:42

0 Answers0