An Outlook user wanted to print only the custom fields in a Task:
Is there any way to hide the default Task fields on a print out? All of the fields appear when I print the task and I only need specific fields.
Although you can't edit the print templates, you can use a macro to create a draft message and print it.
The following code puts together a string containing some of the Task fields of a selected task, including two custom fields, and adds them to a message body. It prints the message then deletes the draft message.
Custom fields are referenced using .UserProperties("fieldname"). Format the date field as "May 3 2014" using Format(olTask.StartDate, "MMM d yyyy") .
To use, select one or more tasks, then run the macro. A message will be created and printed for each task in the selection.
This method is not limited only to tasks; you can use it with any Outlook item type with just a little tweaking of the code to change the fields and item type.
Sub PrintTasks() Dim olTask As Outlook.TaskItem, olMsg As Outlook.MailItem Dim strBody As String For Each olTask In Application.ActiveExplorer.Selection 'put your fields together here strBody = olTask.Subject & vbCrLf & olTask.Body & vbCrLf strBody = strBody & olTask.StartDate & vbCrLf & olTask.UserProperties("Contact Name") & vbCrLf & olTask.UserProperties("Email Address") Set olMsg = Application.CreateItem(olMailItem) With olMsg .BodyFormat = olFormatPlain .Body = strBody ' .Display .PrintOut ' print automatically .Close olDiscard End With Next Set olMsg = Nothing End Sub
How to use macros
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor