Consulting

Results 1 to 4 of 4

Thread: Solved: Application.GetOpenFilename Dialog Box

  1. #1
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location

    Exclamation Solved: Application.GetOpenFilename Dialog Box

    Hi all,

    Can anyone tell me how to customize the dialog box of Get Open FileName?
    How to use the syntax below?

    eg. I only would like to open file with the extension of *.abc or *.xyz? How should we write it?
    Thanks.

    [VBA]
    Dim fName As Variant
    Dim Sep As String

    fName = Application.GetOpenFilename _
    (filefilter:="ABC Files (*.abc), *.*, All Files (*.*), *.*")
    If fName = False Then
    MsgBox "No File Selected"
    Exit Sub
    End If
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,247
    Location
    Quote Originally Posted by sheeeng
    Hi all,

    Can anyone tell me how to customize the dialog box of Get Open FileName?
    How to use the syntax below?

    eg. I only would like to open file with the extension of *.abc or *.xyz? How should we write it?
    Thanks.

    [VBA]
    Dim fName As Variant
    Dim Sep As String

    fName = Application.GetOpenFilename _
    (filefilter:="ABC Files (*.abc), *.*, All Files (*.*), *.*")
    If fName = False Then
    MsgBox "No File Selected"
    Exit Sub
    End If
    [/VBA]
    [VBA]Dim fName As Variant
    Dim Sep As String

    fName = Application.GetOpenFilename _
    (filefilter:="ABC Files (*.abc),*.abc, XYZ Files (*.xyz),*.xyz")
    If fName = False Then
    MsgBox "No File Selected"
    Exit Sub
    End If[/VBA]

    They appear as separate entries in the drop-down. To get both at once, use

    [VBA]Dim fName As Variant
    Dim Sep As String

    fName = Application.GetOpenFilename _
    (filefilter:="Sheeng's Files (*.abc;*.xyz),*.abc;*.xyz")
    If fName = False Then
    MsgBox "No File Selected"
    Exit Sub
    End If[/VBA]

  3. #3
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    268
    Location
    Nice tip, xld. I'd been wondering myself if that was possible.

  4. #4
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Great help, xld. You make this thread solved....

    Thanks a thousands......!!

Posting Permissions

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