open files with knowed names

  • Thread starter Thread starter bris
  • Start date Start date
B

bris

Hi There

I have some file that is used for report generator. From Excel I open some
text files with the "Application.GetOpenFilename("Text Files (*.txt),
*.txt")".
But this function only filters files with extension ".txt". I want also a
filtering. In my example I have a directory with 2 kind of txt*-file, a
testlog.txt and meslog.txt. I only want to see the testlog.txt files, when
the fileopen window is shown.

Br,
Brian
 
Brian,

You can filter only by file extension, not file name.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
What version of excel are you using?

If you use xl2002 or higher, you can use the new .filedialog:
(mostly from the help):
Option Explicit
Sub UseFileDialogOpen()
Dim lngCount As Long
' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "testlog*.txt"
.AllowMultiSelect = True
.Show
' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
MsgBox .SelectedItems(lngCount)
Next lngCount
End With
End Sub
 
Back
Top