Customize File or Folder Dialog Box in VBA Excel
Solution: You can set differ properties of the file-dialog box to look more prettier
Sub CustomizingFileDialog()
Dim fdl As FileDialog
Dim FileChosen As Integer
Set fdl = Application.FileDialog(msoFileDialogFilePicker)
'Set the caption of the dialog box,
fdl.Title = "Please Select a Excel Macro File"
'Set the InitialFile Path
' determine the initial folder selected
fdl.InitialFileName = "c:\"
'Set the Folder View
fdl.InitialView = msoFileDialogViewSmallIcons
'Set the filter
fdl.Filters.Clear
fdl.Filters.Add "Excel Macros Files", "*.xlsm"
FileChosen = fdl.Show
If FileChosen <> -1 Then
'Not choosen anything / Clicked on CANCEL
MsgBox "You have choosen nothing"
Else
'display name and complete path of file chosen
MsgBox fdl.SelectedItems(1)
End If
End Sub
No comments:
Post a Comment