Reputation: 163
when I tried to run it, it showed error with the msoFileDIalogFolderPicker not defined. I already checked reference to Office 14 library but still didnt work?
Dim MyFolder As String 'Path collected from the folder picker dialog
Dim MyFile As String
Dim wbk As Workbook
On Error Resume Next
Application.ScreenUpdating = False
With Application.FileDialog(msoFileDialogFolderPicker)
Upvotes: 2
Views: 3548
Reputation: 4486
I don't have a Mac, but with reference of (https://www.rondebruin.nl/mac/mac017.htm), try the below (you may need to tweak it in places) and see if it does what you need it to:
Sub Select_Folder_On_Mac()
Dim folderPath As String
Dim RootFolder As String
Dim scriptstr As String
On Error Resume Next
RootFolder = MacScript("return (path to desktop folder) as String")
'Or use RootFolder = "Macintosh HD:Users:YourUserName:Desktop:TestMap:"
'Note : for a fixed path use : as seperator in 2011 and 2016
If Val(Application.Version) < 15 Then
scriptstr = "(choose folder with prompt ""Select the folder""" & _
" default location alias """ & RootFolder & """) as string"
Else
scriptstr = "return posix path of (choose folder with prompt ""Select the folder""" & _
" default location alias """ & RootFolder & """) as string"
End If
folderPath = MacScript(scriptstr)
On Error GoTo 0
If folderPath <> "" Then
MsgBox folderPath
End If
End Sub
Upvotes: 2