View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default 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