VBA ChooseFolder
Public Function ChooseFolder() As String '定义并新建一个对话框对象 Dim dlgOpen As FileDialog Set dlgOpen = Application.FileDialog(msoFileDialogFolderPicker) '如果当前没有对话框显示,就让他弹出对话框 If dlgOpen.Show = -1 Then ChooseFolder = dlgOpen.SelectedItems(1) MsgBox (ChooseFolder) Set dlgOpen = Nothing End Function