to show both .xls and .xlsx files while opening

retaliator

New Member
Joined
Sep 23, 2010
Messages
4
I have created a macro that opens other microsoft excel spreadsheet files. I want that when the user browse for the open file then the window that opens shud display both .xls and xlsx files at once. the code i ve used is below:

Dim Finfo As String
Dim FilterIndex As Integer
Dim Title As String
Dim FileName As Variant
' Set up list of file filters
Finfo = "Workbook (*.xls),*.xls," & "Office 2007 Excel Workbook (*.xlsx),*.xlsx,"
' Display *.* by default
FilterIndex = 1
' Set the dialog box caption
Title = "Select a File to Import"
' Get the filename
FileName = Application.GetOpenFilename(Finfo, _
FilterIndex, Title)
' Handle return info from dialog box
If FileName = False Then
MsgBox "No file was selected."
Else
'MsgBox "You selected " & FileName
' opens an the excel file at the location: FileName
Workbooks.Open (FileName)
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
thank you.

m new to vba with some basic knowledge of programming. C++ to be exact. there are so many things that i dunno how to discover. like u ve shown that theres this multiselect option which if enabled would do the job.

i mean how else could i have learned this. theres this object browser option that tells us about the objects and procedure and methods associated with an object but i cannot get much help from there.

so should i just rely on forums like this one to know the things i dunno about.
 
Upvote 0
Did the quoted solution (AllowMultiSelect:=True) work for you? I don't see that it will work (but maybe I am failing to see something?).

I would think that setting the filter to:

Finfo = "Excel Workbooks (*.xls*),*.xls*"

is what you want.
 
Upvote 0
thank u richard n harshab.

i ve tried a few books that got me write code n edit it n i ve become quite adept at it. still i find that everything can be done in a variety of ways n theres no way i can master it.


FileName = Application.GetOpenFilename(Multiselect:=true)

shows all the files, including the ones that are other than excel.



Finfo = "Excel Workbooks (*.xls*),*.xls*"
shows all the types of files with "xls" in their extension. including xlsm.


my purpose is solved but is there any perfect way that wud just show xls and xlsx files and not any other????
 
Upvote 0
Yep:
Code:
Finfo = "Excel Workbooks, *.xls; *.xlsx"
 
Upvote 0
Yep:
Code:
Finfo = "Excel Workbooks, *.xls; *.xlsx"

I have code fname = ActiveCell.Value & ".xls"
I am wondering is there a wildcard that can be used so it will find .xls or .xlsx or .xlm
I tried fname = ActiveCell.Value & ".xls"; ".xlsx" but that does not work
 
Upvote 0
What are you actually doing with fName?
 
Upvote 0

Forum statistics

Threads
1,213,553
Messages
6,114,279
Members
448,562
Latest member
Flashbond

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