如何用VBA打开选择文件和选择路径的对话框

2024-12-27 19:01:45
推荐回答(1个)
回答1:

'在文件对话框对中返回选择一个文件夹的路径. Public Function ChooseFolder() As String Dim dlgOpen As FileDialog Set dlgOpen = Application.FileDialog(msoFileDialogFolderPicker) With dlgOpen If .Show = -1 Then ChooseFolder = .SelectedItems(1)End IfEnd With Set dlgOpen = Nothing End Function '-------------------------------------------------------- '在文件对话框对中,选择一个文件。