A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Printing Tiff/JPG attachment



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 18th 09, 10:42 PM posted to microsoft.public.outlook.program_vba
Henk Pols
external usenet poster
 
Posts: 2
Default Printing Tiff/JPG attachment

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.


  #2  
Old March 25th 09, 01:45 AM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default Printing Tiff/JPG attachment

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" 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.

  #3  
Old March 26th 09, 12:53 AM posted to microsoft.public.outlook.program_vba
Henk Pols
external usenet poster
 
Posts: 2
Default Printing Tiff/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" schreef in bericht
...
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" 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.



  #4  
Old March 26th 09, 11:20 AM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default Printing Tiff/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" 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.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing Attachment Information LarryH Outlook - General Queries 6 October 28th 08 01:11 PM
Attachment Printing RGA[_2_] Outlook - General Queries 2 August 28th 08 03:37 PM
Right click send to mail recipient of an TIFF Cat bite Outlook - General Queries 1 May 24th 06 06:16 AM
printing attachment name in Word Martin Outlook - Using Forms 2 April 7th 06 10:46 AM
How do I convert an incoming TIFF fax to a Adobe PDF? Bob Outlook - Installation 1 April 4th 06 08:41 PM


All times are GMT +1. The time now is 05:14 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.