GetOpenFilename, default to preview

A

Andy

Hi,

Is it possible to change by code the view of the open dialog invoked by the
GetOpenFilename command to the Preview mode if it's not set as default.

Thanks
Andy
 
J

JON JON

Hello Andy,

Try this code. I use the filedialog instead

Sub test()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
.InitialView = msoFileDialogViewPreview
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Microsoft Excel Worksheet", "*.xls"
If .Show = -1 Then 'User Press Open
Workbooks.Open .SelectedItems(1)
End If
End With
Set fd = Nothing
End Sub

HTH

Jon-jon
 
A

Andy

Thanks Jon-jon,
works like a charm.
Andy

JON JON said:
Hello Andy,

Try this code. I use the filedialog instead

Sub test()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
.InitialView = msoFileDialogViewPreview
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Microsoft Excel Worksheet", "*.xls"
If .Show = -1 Then 'User Press Open
Workbooks.Open .SelectedItems(1)
End If
End With
Set fd = Nothing
End Sub

HTH

Jon-jon
 
Top