Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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?

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.



Recommended Productivity Tools

shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121

Kutools for Outlook - More than 100 Advanced Functions for Outlook, Improve 70% Efficiency For you

  • Complicated and repeated operations can be done a one-time processing in seconds.
  • Forward multiple emails individually with one-click, and auto forward by rules.
  • Auto CC/BCC every sending email and easy for customizing rules, and auto reply without requiring exchange server.
  • Powerful junk emails filter, remove duplicate emails, reply with attachment, bunch of one-click operations, and so on...
  • 60-day unlimited free trial. 60-day money back guarantee. 2 years free upgrade and support. Buy once, use forever.
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.