FileDialog Question

bigturnip

New Member
Joined
Nov 11, 2003
Messages
24
When using the file picker or open dialog via the FileDialog property you can select multiple files to open, is it possible to restrict users to only selecting one file?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Good afternoon bigturnip

Use the GetOpenFileName command - it has a series of parameters after it, the fifth one along is a boolean value for multiselect. Just set it to false.

Code:
a = Application.GetOpenFilename(, , , , False)

HTH

DominicB
 
Upvote 0
Code:
Sub test()
  MsgBox FileOpen(ThisWorkbook.path & "\*.xls")
End Sub


Function FileOpen(initialFilename As String) As String
  With Application.FileDialog(msoFileDialogOpen)
    .ButtonName = "&Open"
    .initialFilename = initialFilename
    .Filters.Add "Excel (*.xls)", "*.xls", 1
    .Title = "File Open"
    .AllowMultiSelect = False
    If .Show = -1 Then FileOpen = .SelectedItems(1)
  End With
End Function
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,835
Members
449,192
Latest member
mcgeeaudrey

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top