PDA

View Full Version : Pick a Folder Name in Mac 2011 VBA



mauryb
01-06-2011, 02:56 PM
Hi All.

Does anyone know if msoFileDialogFolderPicker can be used on a Mac?

I appreciate any suggestions on this subject.




Thanks for helping.


mauryb

mikerickson
01-06-2011, 11:55 PM
I'd use this
Dim returnVal As String

returnVal = MacScript("try" & vbLf & "choose folder" & vbLf & "end try")

If returnVal = Chr(0) Then
MsgBox "cancel pressed"
Else
MsgBox "folder chosen: " & vbCr & returnVal
End If

mauryb
01-07-2011, 03:36 PM
mikerickson,

Thank you once again.

I could not get the macscript to work. No surprise there.
You may recall I am writing for a Mac on a Pc.

Your suggestion was still helpful because it did prompt me to look a little more into scripting. I may have been "missing the boat" on this resource.

Less elegant, what I ended up doing was using the Dir() function to create a list box of folders to pick from in a form.

Your time and expertise is really appreciated--especially for the tip on Application.PathSeparator. This was a life saver.


Best,
mauryb

mikerickson
01-09-2011, 12:09 AM
Have you tried conditional compiling.
Sub test()
Dim returnVal As String

#If Mac Then
returnVal = MacScript("try" & vbLf & "choose folder" & vbLf & "end try")
If returnVal = Chr(0) Then returnVal = "False"
#Else
Rem code for Windows
#End If

If returnVal = "False" Then
MsgBox "cancel pressed"
Else
MsgBox "folder chosen: " & vbCr & vbCr & returnVal
End If
End Sub