Open folder specfic file type

Excelnoobisme

Board Regular
Joined
Nov 19, 2010
Messages
128
i have come across the following code to open folder.....

Sub OpenSingleFile()
Dim Filter As String, Title As String
Dim FilterIndex As Integer
Dim Filename As Variant
Filter = "Excel 97-03 (*.xls),*.xls," & _
"Excel 07 (*.xlsx),*.xlsx," & _
"Excel Marco-Enabled (*.xlsm),*.xlsm," & _
"Text Files (*.txt),*.txt," & _
"All Files (*.*),*.*"

FilterIndex = 3
Title = "Select a File to Open"
ChDrive ("S")
ChDir ("S:\Casino Control\Gaming Audit\Slots\Net win vs Mtr win Variance\2011\Net Win vs Meter Win\Aug")
With Application
Filename = .GetOpenFilename(Filter, FilterIndex, Title)
ChDrive (Left(.DefaultFilePath, 1))
ChDir (.DefaultFilePath)
End With
If Filename = False Then
MsgBox "No file was selected."
Exit Sub
End If
Workbooks.Open Filename
End Sub


On the filter which i bold, what is the command to show all excel files, be it .xls, xlsx or xlsm?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try something like this...
Code:
Filter = "Excel Files (*.xls*),*.xls*," & _
"Text Files (*.txt),*.txt," & _
"All Files (*.*),*.*"
FilterIndex = 1
 
Upvote 0
example taken from one of my files, uses ";" to add extra file types. Adjust it as required

Code:
strFilterList = "Excel workbooks and templates, *.xls; *.xlt; *.xlsm; *.xlsx; *.xltm; *.xltx; *.xlsb"
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,270
Members
452,902
Latest member
Knuddeluff

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