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 Sub OpenAcrobat(Item As Outlook.MailItem)
Dim objFSO As Object, _
objTempFolder As Object, _
olkAttachment As Outlook.Attachment
'On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTempFolder = objFSO.GetSpecialFolder(2)
For Each olkAttachment In Item.Attachments
If LCase(objFSO.GetExtensionName(olkAttachment.FileName)) = "pdf" Then
olkAttachment.SaveAsFile objTempFolder & "\" & olkAttachment.FileName
ShellExecute 0&, "open", objTempFolder & "\" & olkAttachment.FileName, 0&, 0&, 0&
End If
Next
Set olkAttachment = Nothing
Set objTempFolder = Nothing
Set objFSO = Nothing
End Sub
|