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)
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)