GetOpenFilename, default to preview

  • Thread starter Thread starter Andy
  • Start date Start date
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
 
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
 
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
 

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

Back
Top