PDA

View Full Version : Combining two working print macros



Tina
07-05-2017, 08:03 AM
I have two macros in Outlook 2010 that work

The first prints an email when it is dropped into a folder. The second one prints the first page of an email. Ideally I want to combine them both but after some experimenting I can't seem to insert the second set of code into the first in the correct place for it to work.

Any help much appreciated

Code one

Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace
Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Parent.Folders("Worldox").Folders(“Joey”).Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
PrintNewItem Item
End If
End Sub
Private Sub PrintNewItem(Mail As Outlook.MailItem)
On Error Resume Next
Mail.PrintOut
End Sub

Code two

Sub PrintPageOne()
SendKeys "%FPR"
SendKeys "%S"
SendKeys "1"
SendKeys "{ENTER}"
End Sub

skatonni
07-13-2017, 12:20 PM
You did not indicate what you tried so I would guess you are running PrintPageOne on the folder not the item.


Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.mailitem Then
'PrintNewItem Item
Item.Display
PrintPageOne
End If
End Sub