Private Sub Command1_Click()
Dim mCob As New CommonDialog
Dim mFileName As String
    With mCod
         .DialogTitle = "打开Exe应用程序"
         .Filter = "应用程序 (*.exe)|*.exe"
         .ShowOpen
         mFileName = .FileName '返回选择的应用程序名
    End With
End Sub运行后,弹出错误:编译错误,无效使用new关键字。

解决方案 »

  1.   

    你那个CommonDialog是不是标准模块啊:)
      

  2.   

    Option ExplicitPrivate Sub Command1_Click()
        'Dim mCob As New CommonDialog
        Dim mCod As Object
        Set mCod = CreateObject("MSComDlg.CommonDialog")
        Dim mFileName As String
          With mCod
          .DialogTitle = "打开Exe应用程序"
          .Filter = "应用程序 (*.exe)|*.exe"
          .ShowOpen
          mFileName = .FileName '返回选择的应用程序名
          End With
    End Sub