+ Reply to Thread
Results 1 to 4 of 4

GetOpenFilename - FileName argument's syntax confusion (*.*)

  1. #1
    Forum Contributor
    Join Date
    06-20-2021
    Location
    UK
    MS-Off Ver
    2016
    Posts
    126

    GetOpenFilename - FileName argument's syntax confusion (*.*)

    Hi,

    I am trying to understand the difference between these two:

    Please Login or Register  to view this content.
    In my understanding without having (*.txt), this gives the same dialog box as without it. So what is the actual point of having written like this?

    Example:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: GetOpenFilename - FileName argument's syntax confusion (*.*)

    No different other than the way the filter description appear in the dropdown list.

    The convention is
    Group Description (*.extension)

    If you look at Excel's, or most other software, Open dialog the File types are described in that way.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: GetOpenFilename - FileName argument's syntax confusion (*.*)

    The behavior of this string has been thought a bug by some but persists. As with all Microsoft code, I have been unable to find a rigorous specification for this string, only a broad description and simple examples.

    Why is it like this? The answer is probably lost in some retired Microsoft engineer's brain.

    My interpretation of the specification string is this BNF, although Microsoft never expresses it this way:

    wildcard_list ::= wildcard[; wildcard]...
    wildcard_list1 ::= wildcard_list
    wildcard_list2 ::= wildcard_list
    description ::= arbitrary text description for display
    specification ::= description[ (wildcard_list1)], wildcard_list2

    The weird thing is that wildcard_list1 and wildcard_list2 do not have to match. This invites the question as to why the specification is not simply
    specification ::= description (wildcard_list)

    Among the oddities:

    If you omit the wildcard in parentheses, the wildcard after the comma is used for the filter and also inserted into the dropdown box item, as described by the OP.

    FInfo = "Text Files, *.txt"
    wildcard1.JPG

    If you put a wildcard that does not match the wildcard after the comma, the one in parentheses will take precedence.

    FInfo = "Text Files (*.pdf), *.txt"
    wildcard2.JPG

    FInfo = "Excel (*.xlsx; *.xlsm), *.txt"
    wildcard3.JPG
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Contributor
    Join Date
    06-20-2021
    Location
    UK
    MS-Off Ver
    2016
    Posts
    126

    Re: GetOpenFilename - FileName argument's syntax confusion (*.*)

    I guess one of the quirks of VBA that I have to learn to live with. I found parenthesis to be more of a filler than anything.

    I see your point of precedence though which is an interesting point.

    Thanks for explanation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] FileDialog vs GetOpenFileName: Wild card, FileName
    By gvaltat in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-13-2014, 03:07 PM
  2. [SOLVED] stdev.p syntax: Number 2 Argument
    By Winship in forum Excel General
    Replies: 4
    Last Post: 02-21-2014, 04:38 PM
  3. [SOLVED] Conflict with GetOpenFilename and Workbooks(x).Close - expected filename and not path
    By knutfh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-17-2013, 04:48 AM
  4. VBA syntax confusion
    By dan2010 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2010, 10:25 AM
  5. Extracting the filename from application.getopenfilename
    By Skyway in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-06-2008, 12:13 PM
  6. Filter Alphanumeric filename in GetOpenFilename
    By akr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2008, 11:47 AM
  7. Set Location and Filename to replace GetOpenFilename
    By David in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2005, 10:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1