Try this:
Code:
Public Function OpenWithShell(ByVal strFilePath As String) As Boolean
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: To open any file in the appropriate application
'Test for file existence to avoid Windows error message
If Not Dir(strFilePath) = vbNullString Then
'Open the file
Shell ("RunDLL32.EXE shell32.dll,ShellExec_RunDLL " & strFilePath)
OpenWithShell = True
End If
End Function
Call it like this:
Code:
Sub OpenFileExample()
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: To demonstrate the use of the OpenWithShell function
Dim strFullFileName As String
'Set path to file
strFullFileName = "C:\My Documents\Some Outlook Message.msg"
'Check if file opened
If OpenWithShell(strFullFileName) = False Then _
MsgBox ("File not opened!")
End Sub
Bookmarks