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

 

posted @ 2023-04-03 10:48  sMei  阅读(33)  评论(0编辑  收藏  举报