请把以下代码贴到模块中:Private Declare Function GetDesktopWindow Lib "user32" () As LongPrivate 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
Private Const SW_SHOWNORMAL = 1Public Function OpenFile(asPath As String,optional PramCommand as string) As Long
On Error Resume Next
Dim Scr_hDC As Long
Scr_hDC = GetDesktopWindow()
If Len(asPath) = 0 Then Exit Function OpenFile = ShellExecute(Scr_hDC, "Open", asPath, PramCommand, "C:\", SW_SHOWNORMAL)
End Function 如果要打开word,直接调用Call OpenFile("C:\Program Files\a\a.doc")或者Call OpenFile(C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE,"C:\Program Files\a\a.doc")
呵呵,你可以给文件地址加双引号。
如
shell "cmd ""c:\a.bat"""