I have removed the second kill line but printing it's not working.
Culd you check my code please?
Private Declare PtrSafe 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)
Private Const SW_SHOWNORMAL = 1
Sub Test1()
Dim msg As MailItem, a As Attachment, m As Attachment, t As MailItem, tmp As String
tmp = "c:\temp\qwerty.msg"
Set msg = ActiveExplorer.Selection(1)
For Each m In msg.Attachments
If LCase(Right(m.FileName, 4)) = ".msg" Then
m.SaveAsFile tmp
Set t = CreateItemFromTemplate(tmp)
For Each a In t.Attachments
If LCase(Right(a.FileName, 4)) = ".pdf" Then
printpdfs a
End If
Next
Kill tmp
Else
'printpdfs m
End If
Next
End Sub
Sub printpdfs(attch As Attachment)
Dim tmpfile As String
tmpfile = "c:\temp\" & attch.FileName
attch.SaveAsFile tmpfile
lngRet = ShellExecute(0, "print", tmpfile, vbNullString, vbNullString, SW_SHOWNORMAL)
'Kill tmpfile
End Sub
Is it correcto to use PtrSafe in the first line?
I have a 64 bit machine