1. ‘浏览文件和文件夹清单
    2. Application.FileDialog(msoFileDialogFilePicker).Show
    3. ‘浏览文件夹清单
    4. Application.FileDialog(msoFileDialogFolderPicker).Show
    5. FileDialog 打开文件夹或文件
    6. Dir 判断文件存在
    7. Sub 按钮1_Click()
    8. '选择单一文件夹
    9. With Application.FileDialog(msoFileDialogFolderPicker)
    10. If .Show = -1 Then
    11. 'FileDialog 对象的 Show 方法显示对话框,并且返回 -1(如果您按 OK)和 0(如果您按 Cancel)。
    12. MsgBox "您选择的文件夹是:" & .SelectedItems(1), vbOKOnly + vbInformation, "智能Excel"
    13. Dim fileOfIndexHtml As String
    14. fileOfIndexHtml = .SelectedItems(1) + "\index.html"
    15. '如果文件不存在就返回空字符串
    16. If Dir(fileOfIndexHtml) = "" Then MsgBox "文件夹中不存在,请重新指定文件目录!" Else MsgBox "该文件存在." + fileOfIndexHtml
    17. End If
    18. End With
    19. End Sub

    ————————————————
    版权声明:本文为CSDN博主「iteye_11020」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/iteye_11020/article/details/82412624

        msoFileDialogFilePicker 允许用户选择文件。
        msoFileDialogFolderPicker 允许用户选择一个文件夹。
        msoFileDialogOpen 允许用户打开文件。
        msoFileDialogSaveAs 允许用户保存一个文件。