How to print PDF from Iphone
Requirements: Microsoft Outlook up and running in your PC
Usage scenario send an email with the required PDF attached from your iPhone to your own outlook email add to the subject link "#print" and create a rule in MS Outlook to copy/move such emails to a folder named "BatchPrints"
Copy the following code
'###############################################################################
'### Module level Declarations
'expose the items in the target folder to events
Option Explicit
Dim WithEvents TargetFolderItems As Items
'set the string constant for the path to save attachments
Const FILE_PATH As String = "C:\Temp\"
'###############################################################################
'### this is the Application_Startup event code in the ThisOutlookSession module
Private Sub Application_Startup()
'some startup code to set our "event-sensitive" items collection
Dim ns As Outlook.NameSpace
'
Set ns = Application.GetNamespace("MAPI")
Set TargetFolderItems = ns.Folders.Item( _
"Personal Folders").Folders.Item("BatchPrints").Items
End Sub
'###############################################################################
'### this is the ItemAdd event code
Sub TargetFolderItems_ItemAdd(ByVal Item As Object)
'when a new item is added to our "watched folder" we can process it
Dim olAtt As Attachment
Dim i As Integer
If Item.Attachments.Count > 0 Then
For i = 1 To Item.Attachments.Count
Set olAtt = Item.Attachments(i)
'save the attachment
olAtt.SaveAsFile FILE_PATH & olAtt.FileName
'if its an Excel file, pass the filepath to the print routine
If UCase(Right(olAtt.FileName, 3)) = "PDF" Then
PrintAtt (FILE_PATH & olAtt.FileName)
End If
Next
End If
Set olAtt = Nothing
End Sub
'###############################################################################
'### this is the Application_Quit event code in the ThisOutlookSession module
Private Sub Application_Quit()
Dim ns As Outlook.NameSpace
Set TargetFolderItems = Nothing
Set ns = Nothing
End Sub
'###############################################################################
'### print routine
Sub PrintAtt(fFullPath As String)
Shell """C:\Program Files\Adobe\Acrobat 7.0\Reader\acrord32.exe"" /h /p """ + fFullPath + """", vbHide
End Sub
Steps
- From Outlook, open the VBEditor (Alt+F11)
- If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
- Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
- Edit the code as needed
- Create an Outlook folder named "BatchPrints" in your Personal folders (or amend the code: Set TargetFolderItems to an existing folder, for instance change the "Personal Folders" to "Exchange User Name folder")
- Create a directory "C:\Temp" (or amend the constant: FILE_PATH to an existing folder)
- Change Shell """C:\Program Files\Adobe\Acrobat 7.0\Reader\acrord32.exe"" , need to change the line of code that calls Acrobat to match the path on your system.
- Save the project
- Restart Outlook (or run the routine "Application_Startup")
No comments:
Post a Comment