ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filter The msoFileDialogOpen (https://www.excelbanter.com/excel-programming/420928-filter-msofiledialogopen.html)

Mike

Filter The msoFileDialogOpen
 
Ive tried to filter this msoFileDialogOpen to only allow excel files to be
selected but cant get it to work. Any help ?
Set FD = Application.FileDialog(msoFileDialogOpen)
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "C:\"
.Title = "(Open excel file)"

If .Show = True Then
.Execute
Else
Exit Sub

End If
End With

OssieMac

Filter The msoFileDialogOpen
 
Hi Mike,

Try this.

Dim FD
Set FD = Application.FileDialog(msoFileDialogOpen)
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel files", "*.*"

'or
'.Filters.Add "All files", "*.xls"

.AllowMultiSelect = False
.InitialFileName = "C:\"
.Title = "(Open excel file)"

If .Show = True Then
.Execute
Else
Exit Sub

End If
End With

--
Regards,

OssieMac


"Mike" wrote:

Ive tried to filter this msoFileDialogOpen to only allow excel files to be
selected but cant get it to work. Any help ?
Set FD = Application.FileDialog(msoFileDialogOpen)
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "C:\"
.Title = "(Open excel file)"

If .Show = True Then
.Execute
Else
Exit Sub

End If
End With


Mike

Filter The msoFileDialogOpen
 
for the life of me I forgot the add

Thanks Ossie

"OssieMac" wrote:

Hi Mike,

Try this.

Dim FD
Set FD = Application.FileDialog(msoFileDialogOpen)
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel files", "*.*"

'or
'.Filters.Add "All files", "*.xls"

.AllowMultiSelect = False
.InitialFileName = "C:\"
.Title = "(Open excel file)"

If .Show = True Then
.Execute
Else
Exit Sub

End If
End With

--
Regards,

OssieMac


"Mike" wrote:

Ive tried to filter this msoFileDialogOpen to only allow excel files to be
selected but cant get it to work. Any help ?
Set FD = Application.FileDialog(msoFileDialogOpen)
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "C:\"
.Title = "(Open excel file)"

If .Show = True Then
.Execute
Else
Exit Sub

End If
End With



All times are GMT +1. The time now is 05:25 PM.

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