File filter, allow xls, xlsx and xlsm and nothing else

jflurrie

New Member
Joined
Sep 22, 2008
Messages
43
Here's the current code:

Code:
Application.GetOpenFilename(FileFilter:="Microsoft Excel Workbooks (*.xls;*.xlsx;*.xlsm)*.xls;*.xlsx;*.xlsm", Title:="Open Database File", MultiSelect:=False)

Gives me Method GetOpenFileName of object Application failed (error 1004).

I'm sure it is not far from working.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Something like?
Code:
fileToOpen = Application.GetOpenFilename(FileFilter:="Excel Workbooks (*.xls*),*.xls*", Title:="Open Database File")
If fileToOpen <> False Then
    MsgBox "Open " & fileToOpen
End If
 
Upvote 0
Here's the current code:

Code:
Application.GetOpenFilename(FileFilter:="Microsoft Excel Workbooks (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm", Title:="Open Database File", MultiSelect:=False)

Gives me Method GetOpenFileName of object Application failed (error 1004).

I'm sure it is not far from working.
You can try this :
Application.GetOpenFilename(FileFilter:="Microsoft Excel Workbooks (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm", Title:="Open Database File", MultiSelect:=False)
 
Upvote 0
Not directed to one post in particular, but just to point out that if you are going to hard code the last letter of the file extension rather than using a wildcard then really you should include all the formats including xlsb (and possibly even the template extensions).
 
Upvote 0
here is what you want
Application.GetOpenFilename(FileFilter:="Microsoft Excel Workbooks (*.xls;),*.xls;(*.xlsx),*.xlsx,(*.xlsm),*.xlsm", Title:="Open Database File", MultiSelect:=False)
 
Upvote 0
correct:
Application.GetOpenFilename(FileFilter:="Microsoft Excel Workbooks (*.xls),*.xls;(*.xlsx),*.xlsx,(*.xlsm),*.xlsm", Title:="Open Database File", MultiSelect:=False)
 
Upvote 0

Forum statistics

Threads
1,222,621
Messages
6,167,112
Members
452,097
Latest member
Marshall813

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top