1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Public Function FichierChoisi() As String
'--- Requires reference to Microsoft Office Object Library.
Dim fDialog As Office.FileDialog
FichierChoisi = ""
'--- Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False '--- not multiple selections
.Title = "Sélectionnez UN fichier"
.Filters.Clear
.Filters.Add "All Files", "*.*"
'--- Show the dialog box.
'--- If the .Show method returns True, the user picked at least one file.
'--- If the .Show method returns False, the user clicked Cancel.
If .Show = True Then
FichierChoisi = fDialog.SelectedItems(1)
End If
End With
Set fDialog = Nothing
End Function |
Partager