1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Function CreateFichier(Comment As String, Extension As String, DefaultFileName As String) As String
Dim fd As FileDialog
'Création de l'objet FileDialog
Set fd = Application.FileDialog(msoFileDialogSaveAs)
'Nom du fichier par défaut
fd.InitialFileName = DefaultFileName
'Définie le filtre portant le n° 1 en tant que filtre par défaut à l'ouverture de la fenêtre
For Index = 1 To fd.Filters.Count
If fd.Filters.Item(Index).Extensions = "*.txt" And LCase(fd.Filters.Item(Index).Description) = "texte unicode" Then
fd.FilterIndex = Index
Exit For
End If
Next Index
'Interdit le choix multiple de fichier
fd.AllowMultiSelect = False
'Détecte si l'utilisateur à appuyer sur OK ou Annuler
If fd.Show = -1 Then
'Récupération du chemin du fichier choisi
CreateFichier = fd.SelectedItems.Item(1)
Else
End If
Set fd = Nothing
End Function |
Partager