Your technology certification is waiting. Enroll in Cloud Class ®
Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
Sub PrintAttachmentToSpecificPrinter(Item As Outlook.MailItem)
Dim wshNet As Object, _
strCurrentDefault As String, _
objFSO As Object, _
objTempFolder As Object, _
olkAttachment As Outlook.Attachment
strCurrentDefault = GetDefaultPrinter()
Set wshNet = CreateObject("Wscript.Network")
'Change the printer name on the next line to that of the printer you want attachments printed to
wshNet.SetDefaultPrinter "Microsoft Office Document Image Writer"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTempFolder = objFSO.GetSpecialFolder(2)
For Each olkAttachment In Item.Attachments
olkAttachment.SaveAsFile objTempFolder & "\" & olkAttachment.FILENAME
ShellExecute 0&, "print", objTempFolder & "\" & olkAttachment.FILENAME, 0&, 0&, 0&
Set wshNet = Nothing
Set objFSO = Nothing
Set objTempFolder = Nothing
Set olkAttachment = Nothing
Function GetDefaultPrinter() As String
Dim strPrinter As String, _
intReturn As Integer
strPrinter = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", strPrinter, Len(strPrinter))
If intReturn Then
strPrinter = UCase(Left(strPrinter, InStr(strPrinter, ",") - 1))
GetDefaultPrinter = strPrinter
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.