Skip to main content

How to print tasks based on category in Outlook?

Author: Xiaoyang Last Modified: 2018-10-22

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?

Print tasks based on categories in different pages manually one by one

Print tasks based on categories in different pages with VBA code


Print tasks based on categories in different pages manually one by one

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:

doc print tasks by category 1

2. And then, all the tasks with the specific color category are listed at once, see screenshot:

doc print tasks by category 2

3. Then, go on clicking File > Print to print out this task list as following screenshot shown:

doc print tasks by category 3

4. Repeat the above steps to print out the lists of tasks with the other color categories one by one manually.


Print tasks based on categories in different pages with VBA code

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:

doc print tasks by category 4

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.


Best Office Productivity Tools

Breaking News: Kutools for Outlook Launches Free Version!

Experience the all-new Kutools for Outlook FREE version with 70+ incredible features, yours to use FOREVER! Click to download now!

๐Ÿค– Kutools AI : Instant pro emails with AI magic--one-click to genius replies, perfect tone, multilingual mastery. Transform emailing effortlessly! ...

๐Ÿ“ง Email Automation: Auto Reply (Available for POP and IMAP)  /  Schedule Send Emails  /  Auto CC/BCC by Rules When Sending Email  /  Auto Forward (Advanced Rules)   /  Auto Add Greeting   /  Automatically Split Multi-Recipient Emails into Individual Messages ...

๐Ÿ“จ Email Management: Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

๐Ÿ“ Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

๐ŸŒŸ Interface Magic: ๐Ÿ˜ŠMore Pretty and Cool Emojis   /  Remind you when important emails come  /  Minimize Outlook Instead of Closing ...

๐Ÿ‘ One-click Wonders: Reply All with Incoming Attachments  /   Anti-Phishing Emails  /  ๐Ÿ•˜Show Sender's Time Zone ...

๐Ÿ‘ฉ๐Ÿผโ€๐Ÿคโ€๐Ÿ‘ฉ๐Ÿป Contacts & Calendar: Batch Add Contacts From Selected Emails  /  Split a Contact Group to Individual Groups  /  Remove Birthday Reminders ...

Instantly unlock Kutools for Outlook with a single clickโ€”permanently free. Don't wait, download now and boost your efficiency!

kutools for outlook features1 kutools for outlook features2
 

 

 

Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations