VB6.0 在代码中直接调用 文件打开对话框,不使用windows控件

    Dim fileDlg As Object           ' 文件对话框
       
    
    ' 变量初始化
    Set fileDlg = CreateObject("MSComDlg.CommonDialog")

  
    ' 打开附件
     fileDlg.DialogTitle = "选择附件文件"
    fileDlg.Filter = "Excel (*.xls;*.xlsx)|*.xls;*.xlsx|" & _
                    "Word (*.doc;*.docx)|*.doc;*.docx|" & _
                    "文本文件(*.txt)|*.txt|" & _
                    "压缩文件(*.rar;*.zip)|*.rar;*.zip|" & _
                    "PDF(*.pdf)|*.pdf"
    fileDlg.FilterIndex = 2
                    
    fileDlg.ShowOpen
    
    If fileDlg.FileName <> "" Then
        sourceFilePath = fileDlg.FileName       ' 取得附件路径
    Else
        rtnResult = True    ' 未打开文件的时候 就不提示错误消息了,所以返回 True
        GoTo EndHandle
    End If