Hi try this out paste into a new form add a command button. F5 it
' code starts here
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
Function RunProg(hangle As Long, lzProgName As String, lpOpenState As VbAppWinStyle) As Long
RunProg = ShellExecute(hangle, "open", lzProgName, vbNullString, vbNullString, lpOpenState)
End Function
Private Sub Command1_Click()
Dim lpReturn As Long
lpReturn = RunProg(Form1.hwnd, "C:\test.txt", vbNormalFocus)
If lpReturn = 2 Then
MsgBox "Error opening file", vbInformation, "Error"
Exit Sub
End If
End Sub
' end of code
When ya dreams come true.
|