|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Printing TIFF/JPG AttachmentI 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. That would depend on what applications are installed that can handle those
file types, and whether or not those applications can be automated at all. You could use a ShellExecute command with a "print" verb and the file path to the image file to call whatever application is registered to handle that file type, but that may or may not work. I know it works for BMP files where MSPaint is the handler, other types might not work. Something like this: Declare 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 Const SW_HIDE = 0 Call ShellExecute(0,"print","c:\\test.bmp", _ vbNullString,vbNullString,SW_HIDE); -- Show quoteHide quoteKen Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Henk Pols" <Henk.P***@wxs.nl> wrote in message news:49c2c4c9$0$6678$703f8584@textnews.kpn.nl... > 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. > > >
Other interesting topics
Working with Outlook Contacts from Access
Start macro creating a mail with contact data and autotext Delegate Exporting Contacts using VBA? avoid syncing birthday date to calendar when saving contact Item Outlook confirmation dialog. Add internet header in Outgoing email? Sample Code Show Sender Address in Tooltip or Customized View Redemption Error code 13 while opening addressbook - vbscript Walking the Inbox Error 2711.An internal error has occurred. (OutlookCDO) |
|||||||||||||||||||||||