ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   filter file extension on remote pc for file open (https://www.excelbanter.com/excel-programming/434709-filter-file-extension-remote-pc-file-open.html)

Ludo

filter file extension on remote pc for file open
 
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

joel

filter file extension on remote pc for file open
 
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

"Ludo" wrote:

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



All times are GMT +1. The time now is 09:29 AM.

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