Hi Diane,
I have used your below script and its a great time saver. Ive adapted it and applied it to one script rule, changing the sDirectory to a diff location.
Tried to duplicate this script calling it a new sub name in new module and changing the sDirectory...then applying to a new script rule and it's not working for some reason, even though exacty the same script other than changes mentioned?
Working Script:
Not working:
1st script saves and prints summary of card takings for the day.
2nd script I wish to do the same but for cash takings.
I think Ive read you literature where is says make the folder move within the vba script rule....but I dont know how to add this. Maybe this is causing the complication. However, the working script rule mirror the above rule steps in outlook (e.g move to folder first/separate from script rule).
Many Thanks
Gareth
I have used your below script and its a great time saver. Ive adapted it and applied it to one script rule, changing the sDirectory to a diff location.
Tried to duplicate this script calling it a new sub name in new module and changing the sDirectory...then applying to a new script rule and it's not working for some reason, even though exacty the same script other than changes mentioned?

Working Script:
Code:
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) As Long
Sub PrintAttachments(oMail As Outlook.MailItem)
Dim colAtts As Outlook.Attachments
Dim oAtt As Outlook.Attachment
Dim sFile As String
Dim sDirectory As String
Dim sFileType As String
sDirectory = "G:\My Drive\Outlook attachments\End of Day\Sage\"
Set colAtts = oMail.Attachments
If colAtts.Count Then
For Each oAtt In colAtts
' This code looks at the last 4 characters in a filename
sFileType = LCase$(Right$(oAtt.FileName, 4))
Select Case sFileType
' Add additional file types below
Case ".pdf", ".doc", "docx"
sFile = sDirectory & oAtt.FileName
oAtt.SaveAsFile sFile
ShellExecute 0, "print", sFile, vbNullString, vbNullString, 0
End Select
Next
End If
End Sub
Not working:
Code:
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) As Long
Sub PrintAttachmentsCash(oMail As Outlook.MailItem)
Dim colAtts As Outlook.Attachments
Dim oAtt As Outlook.Attachment
Dim sFile As String
Dim sDirectory As String
Dim sFileType As String
sDirectory = "G:\My Drive\Outlook attachments\Cash Sheet\"
Set colAtts = oMail.Attachments
If colAtts.Count Then
For Each oAtt In colAtts
' This code looks at the last 4 characters in a filename
sFileType = LCase$(Right$(oAtt.FileName, 4))
Select Case sFileType
' Add additional file types below
Case ".pdf", ".doc", "docx"
sFile = sDirectory & oAtt.FileName
oAtt.SaveAsFile sFile
ShellExecute 0, "print", sFile, vbNullString, vbNullString, 0
End Select
Next
End If
End Sub
1st script saves and prints summary of card takings for the day.
2nd script I wish to do the same but for cash takings.

I think Ive read you literature where is says make the folder move within the vba script rule....but I dont know how to add this. Maybe this is causing the complication. However, the working script rule mirror the above rule steps in outlook (e.g move to folder first/separate from script rule).
Many Thanks
Gareth