Add filters to application filedialog

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Add filters to application filedialog

Post by YasserKhalil »

Hello everyone
I have this line of code that enables me to filter excel files only

Code: Select all

.Filters.Add "Excel Files (*.xls; *.xlsx; *.xlsm)", "*.xls; *.xlsx; *.xlsm", 1
The line works but I need to make the list in the filedialog window to display also each extension separately
so the list should be `Excel Files` and `xls` and `xlsx` & `xlsm`

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Add filters to application filedialog

Post by HansV »

If you want one entry per extension:

Code: Select all

        .Filters.Add "Excel Workbooks (*.xlsx)", "*.xlsx"
        .Filters.Add "Excel Macro-Enabled Workbooks (*.xlsm)", "*.xlsm"
        .Filters.Add "Excel Binary Workbooks (*.xlsb)", "*.xlsb"
        .Filters.Add "Excel 97-2003 Workbooks (*.xls)", "*.xls"
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Add filters to application filedialog

Post by YasserKhalil »

Thank you very much my tutor. Is it possible to make these four lines in just one line.

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Add filters to application filedialog

Post by HansV »

I don't understand what you want.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Add filters to application filedialog

Post by YasserKhalil »

I mean to use one line of Filters.Add to add all the desired extensions.

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Add filters to application filedialog

Post by HansV »

The line

Code: Select all

.Filters.Add "Excel Files", "*.xls; *.xlsx; *.xlsm"
will display this:

S0007.png

So what exactly is the problem?
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4931
Joined: 31 Aug 2016, 09:02

Re: Add filters to application filedialog

Post by YasserKhalil »

Thank you very much my tutor
Best Regards