

Excel开发编程
【Excel VBA】FileDialog 用法之 打开对话框获得文件夹路径
2013-07-27 09:34:30
FileDialog 可以根据后面的参数,打开通用对话框 Dim strPath As String Dim MyFileDialog As FileDialog Set MyFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
If MyFileDialog.Show = -1 Then '使用循环显示选取文件的路径和名称 For Each vrtSelectedItem In MyFileDialog.SelectedItems strPath = vrtSelectedItem Next End If
MsgBox strPath 这段代码,可以打开一个对话框,选择文件夹,获得选择的文件夹的路径