If Not rc > 32 Then MsgBox "Open File False!", vbInformation, Me.Caption End IfPrivate 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_MAXIMIZE = 3 Private Const SW_MINIMIZE = 6 Private Const SW_NORMAL = 1 Private Const SW_HIDE = 0Private 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 0, "open", "c:\words\1.doc", vbNullString, vbNullString, SW_MAXIMIZE End Sub
strPathName = VBA.Left(strPath, intPathLen - 1)
rc = ShellExecute(0, "open", strPath, "", strPathName, 1)
If Not rc > 32 Then
MsgBox "Open File False!", vbInformation, Me.Caption
End IfPrivate 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_MINIMIZE = 6
Private Const SW_NORMAL = 1
Private Const SW_HIDE = 0Private 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 0, "open", "c:\words\1.doc", vbNullString, vbNullString, SW_MAXIMIZE
End Sub