Hi Joey,
You can use the ShellExecute API function for this. Basically, when used
with the "open" verb, ShellExecute will open the specified file with its
default application. Here's the code needed to do it:
Private Const SW_SHOWMAXIMIZED = 3
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
Public Function gbOpenFile(rsPath As String) As Boolean
If ShellExecute(0, "open", rsPath & vbNullChar, _
vbNullString, vbNullString, SW_SHOWMAXIMIZED) > 32 Then
gbOpenFile = True
End If
End Function
There are other SW_* constants that determine how the window is displayed.
There are lots of return value constants that can help you trap runtime
errors (instead of just checking for > 32), too - just look for shellexecute
on MSDN for more info on them.
--
Regards,
Jake Marx
MS MVP - Excel
www.longhead.com
[please keep replies in the newsgroup - email address unmonitored]