Consulting

Results 1 to 6 of 6

Thread: GetOpenFilename

  1. #1

    GetOpenFilename

    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

  2. #2
    Can you post excel sample ?

  3. #3
    VBAX Mentor tpoynton's Avatar
    Joined
    Feb 2005
    Location
    Clinton, MA
    Posts
    399
    Location
    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:
    [vba]
    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[/vba]

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

  4. #4
    You are correct - I am using a filter. I'll remove it and see what happens. thank you

  5. #5
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Look in Help, there is a Mac specific format for showing only certain types of files, eg. text,Excel,Word..

  6. #6
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    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.

    [VBA]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
    [/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •