How to print tasks based on category in Outlook?
Supposing, there are various color categories in your Outlook tasks, and now, you want to print the lists of tasks based on the categories in different pages. How could you solve this job in Outlook?
In Outlook, you can manually print the tasks based on the different categories in different pages one by one, please do as this:
1. Launch the Outlook, and go to the Task pane and select the task folder you want to print, and then press Ctrl + E to activate the Search box, and then under the Search tab, click Categorized icon, and choose one color category you need to print, see screenshot:
2. And then, all the tasks with the specific color category are listed at once, see screenshot:
3. Then, go on clicking File > Print to print out this task list as following screenshot shown:
4. Repeat the above steps to print out the lists of tasks with the other color categories one by one manually.
Here is a VBA code which can help you to print the tasks based on the category in different pages at once, please do with following steps:
1. Go to the Task pane and select the task folder that you want to print.
2. Then, hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
3. And then, click Insert > Module, copy and paste below code into the opened blank module:
VBA code: Print tasks based on categories in different pages:
Sub PrintTaskList_SpecificColorCategory() Dim xTaskItems As Outlook.Items Dim xTask As Outlook.TaskItem Dim xDictionary As Scripting.Dictionary Dim xCategoryArr As Variant, xCategory As Variant Dim xExcelApp As Excel.Application Dim xExcelWorkbook As Excel.Workbook Dim xExcelWorksheet As Excel.Worksheet Dim xSheet As Excel.Worksheet Dim xKey As Variant Dim xKeyStr As String Dim i As Long, xLastRow As Integer On Error Resume Next If Application.ActiveExplorer.CurrentFolder.DefaultItemType <> olTaskItem Then Exit Sub Set xTaskItems = Application.ActiveExplorer.CurrentFolder.Items Set xDictionary = New Scripting.Dictionary For Each xTask In xTaskItems xCategoryArr = Split(xTask.Categories, ",") For Each xCategory In xCategoryArr If xDictionary.Exists(Trim(xCategory)) = False Then xDictionary.Add Trim(xCategory), 0 End If Next Next If xDictionary.Count = 0 Then MsgBox "The current Task doesn’t have any category", vbOKOnly + vbInformation, "Kutools for Outlook" Exit Sub End If Set xExcelApp = New Excel.Application Set xExcelWorkbook = xExcelApp.Workbooks.Add xExcelApp.Visible = True i = 0 If xDictionary.Count > xExcelWorkbook.Sheets.Count Then xExcelWorkbook.Sheets.Add Count:=xDictionary.Count - xExcelWorkbook.Sheets.Count End If For Each xKey In xDictionary.Keys xKeyStr = CStr(xKey) i = i + 1 Set xExcelWorksheet = xExcelWorkbook.Sheets(i) xExcelWorksheet.Name = xKeyStr With xExcelWorksheet .Range("A1") = xKeyStr .Range("A1").Font.Bold = True .Range("A1").Font.Size = 18 .Range("A1", "C1").HorizontalAlignment = xlCenter .Range("A1", "C1").VerticalAlignment = xlCenter .Range("A1", "C1").Merge .Range("A2") = "Subject" .Range("A2").Font.Bold = True .Range("B2") = "Start Date" .Range("B2").Font.Bold = True .Range("C2") = "Due Date" .Range("C2").Font.Bold = True End With For Each xTask In xTaskItems If InStr(xTask.Categories, xKeyStr) > 0 Then xLastRow = xExcelWorksheet.UsedRange.Rows.Count + 1 With xExcelWorksheet .Range("A" & xLastRow) = xTask.Subject .Range("B" & xLastRow) = xTask.StartDate .Range("C" & xLastRow) = xTask.DueDate End With End If Next xExcelWorksheet.Columns("A:C").AutoFit Next For Each xSheet In xExcelWorkbook.Sheets xSheet.PrintOut Next xExcelWorkbook.Close False xExcelApp.Quit End Sub
4. Then click Tools > References in the Microsoft Visual Basic for Applications window, in the popped out References-Project1 dialog box, check Microsoft Excel Object Library and Microsoft Scripting Runtime options from the Available References list box, see screenshot:
5. And then, click OK button, now, press F5 key to run this code, after finishing the code, the lists of tasks with different categories will be printed in different pages.
- Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
- BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
- Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
- Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
- Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.