ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filter only shortcuts and xl files (https://www.excelbanter.com/excel-programming/380619-re-filter-only-shortcuts-xl-files.html)

Chip Pearson

Filter only shortcuts and xl files
 
Try

Dim WB As Workbook
Dim FName As String
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel Files", "*.xls", 1
.FilterIndex = 1
.InitialFileName = "%UserProfile%\My Documents"
.AllowMultiSelect = False
If Not .Show Then Exit Sub
FName = .SelectedItems(1)
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Steven" wrote in message
...
I have the following code:

Private Sub OpenMyDocuments()
On Error GoTo ErrMacro

Dim FName As String
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "%UserProfile%\My Documents"
.AllowMultiSelect = False
If Not .Show Then Exit Sub
FName = .SelectedItems(1)
End With

If Len(FName) 0 Then
Set wb = Workbooks.Open(FName)
End If

Application.RecentFiles.Add Name:=FName

Windows("Notes.xls").Close (0)

ErrMacro:

End Sub

It shows - All Files (*.*) - in the Files of Type field. How do I make
it
default to - All Microsoft Office Excel Files - ?

Thank you for your help.

Steven





All times are GMT +1. The time now is 04:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com