PDA

View Full Version : GetOpenFilename



starl
02-25-2010, 09:52 AM
Client trying to open workbook on mac. The program imports data into the workbook from another file. It uses GetOpenFilename. It appears the Mac does not recognize GetOpenFilename.

What does it recognize? how can I allow the user to browse for the desired file?

thanks

domfootwear
02-25-2010, 06:11 PM
Can you post excel sample ?

tpoynton
02-25-2010, 07:06 PM
it works; problem is probably with using an optional filefilter. alternative methods of using filefilter for the mac are documented in the VBA mac help file. While not explicitly stated, I'm pretty sure wildcards do not work on the mac (please correct me if I am wrong).

SO, you can either get rid of the filefilter, or do something like:

If RunningOnMac = True Then
FileName = Application.GetOpenFilename(Title:="Browse for file")
Else
FileName = Application.GetOpenFilename("Excel files (*.xl*),*.xl*", _
1, "Browse for file", , False)
End If

as you can see, I opted here not to deal with the filefilter on the mac, but did use it in windows.

starl
02-26-2010, 12:16 PM
You are correct - I am using a filter. I'll remove it and see what happens. thank you

mikerickson
04-05-2010, 11:34 AM
Look in Help, there is a Mac specific format for showing only certain types of files, eg. text,Excel,Word..

mikerickson
04-05-2010, 12:40 PM
The first sub should do the filtering that you sought in the OP.
The second will get you the file type of a particular file, for use in GetOpenFileName.

Sub test()
MsgBox Application.GetOpenFilename(filefilter:="XLS8,XLS4")
End Sub

Sub GetFileType()
MsgBox MacScript("tell application ""finder"" " & vbCr & "try" & vbCr _
& "return file type of file ((choose file) as alias)" & vbCr & "end try" & vbCr _
& "end tell")
End Sub