Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long    ShellExecute 0, "open", 文件名, vbNullString, vbNullString, 3

解决方案 »

  1.   

    Shell "explorer c:\aaa.bmp"类似这样,会自动用关联程序打开文件。
      

  2.   

    Shell "explorer c:\aaa.csv", 4类似这样,会自动用关联程序打开文件。
      

  3.   

    Private Declare Function WinExec Lib "kernel32" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long
    Private Sub Form_Load()
        WinExec "xxx.doc", 10    WinExec "xxx.bmp", 10    WinExec "xxx.dwg", 10End Sub
      

  4.   

    Shell "explorer c:\aaa.csv", 4类似这样,会自动用关联程序打开文件。
      

  5.   

    Private Declare Function WinExec Lib "kernel32" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long
    Private Sub Form_Load()
        WinExec "xxx.doc", 10    WinExec "xxx.bmp", 10    WinExec "xxx.dwg", 10End Sub
      

  6.   

    直接用shell就可以
     Shell ("C:\Program Files\Microsoft Office\Office\winword d:\d.doc")
      

  7.   

    to griefforyou(为你伤心) :
    怎么没有反应?to : zyl910(910:分儿,我来了!) (L2002) 
    打开了,但是为什么,打开了bmp文件,就不能打开word文件??
      

  8.   

    你机器上有没有word软件?
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command1_Click()
        ShellExecute Me.hwnd, "Open", "C:\aa.doc", "", App.Path, 1
    End SubPrivate Sub Command2_Click()
        ShellExecute Me.hwnd, "Open", "C:\aa.bmp", "", App.Path, 1
    End SubPrivate Sub Command3_Click()
        ShellExecute Me.hwnd, "Open", "C:\aa.csv", "", App.Path, 1
    End Sub'或不用api
    Private Sub Command1_Click()
        Shell "Start.exe  C:\aa.doc", 1
    End SubPrivate Sub Command2_Click()
        Shell "Start.exe  C:\aa.bmp", 1
    End SubPrivate Sub Command3_Click()
        Shell "Start.exe  C:\aa.csv", 1
    End Sub
      

  9.   

    你机器上有没有word软件?
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command1_Click()
        ShellExecute Me.hwnd, "Open", "C:\aa.doc", "", App.Path, 1
    End SubPrivate Sub Command2_Click()
        ShellExecute Me.hwnd, "Open", "C:\aa.bmp", "", App.Path, 1
    End Sub
    '.....'或不用api
    Private Sub Command1_Click()
        Shell "Start.exe  C:\aa.doc", 1
    End Sub'......
      

  10.   

    ok,成功了.谢谢你们!autoCAD也能好用吧??
      

  11.   

    用ShellExecute好象不能打开txt文件,notepad.exe是起动了,但没有弹出个窗口来.