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() On Error GoTo EH With CommonDialog1 .Filter = "Word file(*.doc)|*.doc" .CancelError = True .ShowOpen
ShellExecute Me.hwnd, "", .FileName, "", "", 1 End With Exit SubEH: If Err.Number = 32755 Then Exit Sub
MsgBox "Realtime Error: " & Err.Number & vbCrLf & Err.Description End Sub
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()
On Error GoTo EH
With CommonDialog1
.Filter = "Word file(*.doc)|*.doc"
.CancelError = True
.ShowOpen
ShellExecute Me.hwnd, "", .FileName, "", "", 1
End With
Exit SubEH:
If Err.Number = 32755 Then Exit Sub
MsgBox "Realtime Error: " & Err.Number & vbCrLf & Err.Description
End Sub