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 Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWDEFAULT = 10
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_SHOWNOACTIVATE = 4
Private Sub Command1_Click()
Dim lngHandle As Long
Dim strFile As String
Dim strDir As String
strFile = "C:\Documents and Settings\Carl\Desktop\Example.xls"
strDir = "C:\Documents and Settings\Carl\Desktop"
lngHandle = ShellExecute(Me.hwnd, "Open", strFile, vbNullString, strDir, SW_SHOWNORMAL)
If lngHandle <= 32 Then
MsgBox "Opening excel failed"
Else
MsgBox "Successful" & vbCr & vbCr & _
"The handle to the new excel window is " & lngHandle
End If
End Sub