filter file extension on remote pc for file open

L

Ludo

Hi,

I'm using the code below to select a certain log file on a remote PC.
------------------------------------------
frmSelectKast.Show
If CancelSelect = 1 Then Exit Sub
With Application.FileDialog(msoFileDialogOpen)
If HassKast = 1 Then
.InitialFileName = "\\Kndclt21079\barcoview\Bvw_DMT
\bvw_av_prog\Bin\Logs" 'FMT LOG files kast 1 !!!
.Title = "FMT LOG files kast 1"
Else
.InitialFileName = "\\Kndclt21063\logs" 'FMT LOG files
kast 2 !!!
.Title = "FMT LOG files kast 2"
End If
.Filters.Add "FMT LOG files", "*.log", 1
.FilterIndex = 1
.AllowMultiSelect = False
.InitialView = msoFileDialogViewDetails
.Show
If .SelectedItems.Count = 0 Then Exit Sub
FName = .SelectedItems(1)
End With
-------------------------------
The idea is to select only the *.log files on the remote PC
Thats why i use following lines in the code:
.Filters.Add "FMT LOG files", "*.log", 1
.FilterIndex = 1

But if my dialog opens up there appears an other type of file in the
"Files of type " textbox.
I expect that the *.log would be the first (and only?) kind of files
that would be visible.

What is going wrong here?

Any help welcome

regards,
Ludo
 
J

Joel

I set a property to the dialog object to make it easier to debug. I got only
one entry. I'm thinking you may need to clear the filters before adding a new
one. See code below.


Set Mydialog = Application.FileDialog(msoFileDialogOpen)
With Mydialog
.InitialFileName = "\\XYZ"
.Title = "FMT LOG files kast 1"
.Filters.Clear
.Filters.Add "FMT LOG files", "*.log", 1
.FilterIndex = 1
.AllowMultiSelect = False
.InitialView = msoFileDialogViewDetails
.Show
If .SelectedItems.Count = 0 Then Exit Sub
FName = .SelectedItems(1)
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top