怎样打开本文件夹下已存在txt文件用Shell "App.Path & \123.txt "的语句,给出的提示是文件未找到。

解决方案 »

  1.   

    使用API函数ShellExcute可以实现Option Explicit
    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()
        Dim lngP As Long
        lngP = ShellExecute(Me.hwnd, "Open", "D:\新建 文本文档.txt", vbNullString, vbNullString, 3)
    End Sub
      

  2.   

    Private Sub Command1_Click()
        Dim RetVal
        RetVal = Shell("C:\WINDOWS\system32\notepad.EXE " & App.Path & "\123.txt", 1)
    End Sub
      

  3.   

    多谢,
    其实3楼的可以无需调用函数直接用
    Shell "notepad D:\新建 文本文档.txt"
    即可