Operating system:: Windows 11
Outlook version: Outlook 2021 64bit
Email type or host: IMAP
Outlook version: Outlook 2021 64bit
Email type or host: IMAP
Hello All
I have the following script running to automatically print PDF attachments
Public Sub PrintPDFAttachments(Item As Outlook.MailItem)
Dim Atmt As Attachment
Dim FileName As String
Dim TempFolder As String
Dim objShell As Object
' Set a temporary directory (ensure this path exists or use Environ)
TempFolder = Environ("USERPROFILE") & "\Documents\TempPrint\"
If Dir(TempFolder, vbDirectory) = "" Then MkDir TempFolder
For Each Atmt In Item.Attachments
' Only process PDF files
If LCase(Right(Atmt.FileName, 4)) = ".pdf" Then
FileName = TempFolder & Atmt.FileName
Atmt.SaveAsFile FileName
' Use ShellExecute to print to default printer
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(0).ParseName(FileName).InvokeVerbEx ("print")
End If
Next Atmt
End Sub
I'm seeing some corrution in the characters when PDF are printed (ascii charaters instead of text). Having changed all the hardware including the PC and the printer I'm wondering if the PC is trying to print too many PDF's at the same time. This is used on the main invoice processing PC and they get a lot of invoices that arrive at the same time from various suppliers.
What command(s) can I use please that will force the VB script to print 1 attachment and then wait 3 seconds before printing the next
Thank you in advance!
I have the following script running to automatically print PDF attachments
Public Sub PrintPDFAttachments(Item As Outlook.MailItem)
Dim Atmt As Attachment
Dim FileName As String
Dim TempFolder As String
Dim objShell As Object
' Set a temporary directory (ensure this path exists or use Environ)
TempFolder = Environ("USERPROFILE") & "\Documents\TempPrint\"
If Dir(TempFolder, vbDirectory) = "" Then MkDir TempFolder
For Each Atmt In Item.Attachments
' Only process PDF files
If LCase(Right(Atmt.FileName, 4)) = ".pdf" Then
FileName = TempFolder & Atmt.FileName
Atmt.SaveAsFile FileName
' Use ShellExecute to print to default printer
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(0).ParseName(FileName).InvokeVerbEx ("print")
End If
Next Atmt
End Sub
I'm seeing some corrution in the characters when PDF are printed (ascii charaters instead of text). Having changed all the hardware including the PC and the printer I'm wondering if the PC is trying to print too many PDF's at the same time. This is used on the main invoice processing PC and they get a lot of invoices that arrive at the same time from various suppliers.
What command(s) can I use please that will force the VB script to print 1 attachment and then wait 3 seconds before printing the next
Thank you in advance!