Printing Tiff/JPG attachment

Status
Not open for further replies.
H

Henk Pols

Does anyone have the vba code to print an Tiff/JPG attachment?

I am writng a code that will print a selected E-mail and all attached

documents. So far Iam able to print .doc and .xls attachments, I am missing

the correct code to print .tif and .jpg attachment.

Below is my code sofar:

Sub MyPrint()

Dim myOlApp As New Outlook.Application

Dim myOlExp As Outlook.Explorer

Dim myOlSel As Outlook.Selection

Dim Atmt As Attachment

Dim FileName As String

Dim PrtProg As String

Dim cmd As String

Dim x As Integer

Set myOlExp = myOlApp.ActiveExplorer

Set myOlSel = myOlExp.Selection

For x = 1 To myOlSel.Count

myOlSel.Item(x).PrintOut

For Each Atmt In myOlSel.Item(x).Attachments

FileName = "C:\Windows\Temp\" & Atmt.FileName

Atmt.SaveAsFile FileName

Select Case Right(FileName, 3)

Case "xls":

Dim xlApp As Excel.Application

Dim wb As Excel.Workbook

Set xlApp = New Excel.Application

Set wb = xlApp.Workbooks.Open(FileName)

wb.PrintOut

xlApp.Quit

Set wb = Nothing

Set xlApp = Nothing

Case "doc":

Dim wdApp As Word.Application

Dim doc As Word.Document

Set wdApp = New Word.Application

Set doc = wdApp.Documents.Open(FileName)

doc.PrintOut

wdApp.Quit False

Set doc = Nothing

Set wdApp = Nothing

Case "tiff":

Case "jpg":

Case "bmp":

Case "pdf": 'Via Arobat32.exe

Case "dwg": 'Via ACad32

Case Else:

End Select

Next Atmt

Next x

End Sub

Thanks in advance for any input on this issue.
 
If you have a program that can print images using command line

switches, just call it using the Shell function.

Shell "C:\image_printer\image_printer.exe", vbHide

For example, Irfanview has a /print option which can print an image to

the default printer and then close the program. So it would be

something like

Shell "C:\your path to Irfanview\irfanview.exe /print" &

yourfilename.jpg

HTH,

JP

On Mar 18, 6:42 pm, "Henk Pols" <Henk.P...@wxs.nl> wrote:
> Does anyone have the vba code to print an Tiff/JPG attachment?

> I am writng a code that will print a selected E-mail and all attached
> documents. So far Iam able to print .doc and .xls attachments, I am missing
> the correct code to print .tif and .jpg attachment.
>
 
JP Thanks for your input, however I have already solved the issue.

For you info I use the following code:

Case "bmp", "jpg", "tif":

Dim PCmd, objShell, oExec

Dim Printer As String

Printer = GetDefaultPrinter ' Own declared Function

PCmd = "rundll32 shimgvw.dll,ImageView_PrintTo /pt """ &

FileName & """ """ & Printer

Set objShell = CreateObject("Wscript.Shell")

Set oExec = objShell.Exec(PCmd)

Do While oExec.Status = 0

WScript.Sleep 100

Loop

' Clean up

Set oExec = Nothing

Set objShell = Nothing

Henk.

"JP" <jp2112@earthlink.net> schreef in bericht

news:ca601d92-9f54-42ed-a993-2b98c977b435@33g2000yqm.googlegroups.com...

If you have a program that can print images using command line

switches, just call it using the Shell function.

Shell "C:\image_printer\image_printer.exe", vbHide

For example, Irfanview has a /print option which can print an image to

the default printer and then close the program. So it would be

something like

Shell "C:\your path to Irfanview\irfanview.exe /print" &

yourfilename.jpg

HTH,

JP

On Mar 18, 6:42 pm, "Henk Pols" <Henk.P...@wxs.nl> wrote:
> Does anyone have the vba code to print an Tiff/JPG attachment?

> I am writng a code that will print a selected E-mail and all attached
> documents. So far Iam able to print .doc and .xls attachments, I am
> missing
> the correct code to print .tif and .jpg attachment.
>
 
Thanks for sharing, I'm sure there are others with the same issue who

could use your code.

--JP

On Mar 25, 8:53 pm, "Henk Pols" <Henk.P...@wxs.nl> wrote:
> JP Thanks for your input, however I have already solved the issue.
> For you info I use the following code:
>             Case "bmp", "jpg", "tif":
>                 Dim PCmd, objShell, oExec
>                 Dim Printer As String

>                 Printer = GetDefaultPrinter     ' Own declared Function
>                 PCmd = "rundll32 shimgvw.dll,ImageView_PrintTo /pt """ &
> FileName & """ """ & Printer
>                 Set objShell = CreateObject("Wscript.Shell")
>                 Set oExec = objShell.Exec(PCmd)

>                 Do While oExec.Status = 0
>                     WScript.Sleep 100
>                 Loop
>                 ' Clean up
>                 Set oExec = Nothing
>                 Set objShell = Nothing
> Henk.
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Appointment font size when printing only changes Tasks' font Using Outlook 0
A How to use calender printing? Using Outlook 1
M Printing Appointments Using Outlook 1
M Calendar daily Appointments and printing Using Outlook 0
T Printing from Outlook is now defaulting to "Shrink to Fit"! Using Outlook 5
W Automatically open attachments without automatically printing them Using Outlook 0
S Outlook 2007 printing wrong email address at top of page Using Outlook 8
snissen Printing foreign language messages Using Outlook 1
L printing contacts Using Outlook 1
A How to get rid of Contacts field when printing emails? Using Outlook 0
Diane Poremsky Printing Calendars with Color Categories Using Outlook 0
D VBA macro printing attachments in shared mailbox Outlook VBA and Custom Forms 1
D Printing Contacts Using Outlook 2
C Printing tasks with multiple categories Using Outlook 5
P Printing PDF attachments of Outlook message attachments Outlook VBA and Custom Forms 2
S macro for opening attachments and printing Using Outlook 1
J Printing Mulitple Calendars Outlook VBA and Custom Forms 1
P printing weekly calendar in Outlook 2013 cuts days of week off Using Outlook 1
M Calendar Printing Assistant Hangs only on specific Template Using Outlook 2
G booklet printing in outlook 2007 Using Outlook 1
W Meeting printing background fields Using Outlook 0
K calendar printing Using Outlook 1
M Outlook 2013 is printing headers only Using Outlook 4
B Printing Advanced Search Output Screen Using Outlook 5
S So Disappointed in Calendar Printing Assistant!! Using Outlook 2
D Printing Attachments Automatically in Outlook 2010 Using Outlook 1
F Printing all day events only Using Outlook 3
J outlook printing Using Outlook 2
J Printing Calendar in Outlook 2013 Using Outlook 0
C Printing Outlook Form Controls via Word Using Outlook 11
E Printing Using Outlook 1
C Custom .oft / Printing Issue(s) Using Outlook 1
K Printing & Saving Outlook Contacts Using Outlook 3
P Printing Issues in Outlook 2007 Using Outlook 1
E Outlook 2010 network printing problems Using Outlook 4
L Auto printing unread email + attachments in Inbox - Outlook 2010 - (New user) Using Outlook 1
I Printing Using Outlook 0
E Monthly Style Calendar Printing Using Outlook 6
S How to remove tracking from printing - outlook 2010 Using Outlook 4
P Printing calendar (work week) with numerous (i.e. >7) all day events... Using Outlook 3
A Outlook CPAO - Printing Monthly calendar with only all day events or catergory Using Outlook 2
E Adding Start and End Time to Daily View in Calendar Printing assistant Using Outlook 1
M Outlook 2010 task line printing Using Outlook 1
S Printing Selected Date Range in Monthly Style Using Outlook 1
S Does Printing Assistant Work with Windows 8 and Office 10? Using Outlook 1
A outlook printing assistant Help editing template Using Outlook 3
S Printing Category Key on Calendar Using Outlook 1
P Printing Issue on Calendar Printing Assistant Using Outlook 0
W Calendar Printing with Outlook 2010 (64 bit) Using Outlook 1
R printing fields in addresses Using Outlook 1

Similar threads

Back
Top