Chapter 26. Creating Custom Views and Print Styles

Creating and Using Custom Views 653

Printing in Outlook 668

Custom Printing with Scripts and Word 676

Custom Printing with Excel 684

EARLIER chapters in this book discussed the standard views that Microsoft Outlook 2010 provides for its many folders and data types. Those chapters also discussed customizing standard views by grouping and sorting items and by adding and removing columns, changing column order and properties, filtering the view, and so on.

In this chapter, you’ll learn how to create custom views in Outlook 2010 to present the information you want in a format that suits your needs. Because generating a printed version of your data is often a byproduct of creating a view, this chapter also focuses on how to create custom print styles in Outlook 2010. For those situations in which the Outlook 2010 custom views and print styles won’t give you the results you need, you can turn to scripts and Microsoft Word 2010 to accomplish custom printing tasks.

Note

For more information about customizing existing views, see the section Working with the Standard Outlook Views, on page 72. You’ll also find information about specific views in the chapters that cover them. For example, for more information about working with and customizing views in the Contacts folder, see the section Viewing Contacts, on page 452.

If the options for customizing existing Outlook 2010 views don’t provide the information view that you need, you can create your own views. You have two options for doing this: modifying an existing view or creating a new view from scratch.

You can create a new, custom view from an existing view if the existing one offers most of the view elements that you need. This is usually the easiest method because it requires the least amount of work.

Follow these steps to create a new, custom view from an existing view:

  1. Open the folder for which you want to modify the view, and then select the view to display it.

  2. On the View tab, click Change View and choose Save Current View As A New View to open the Copy View dialog box, shown in Figure 26-1.

  3. In the Copy View dialog box, type a name in the Name Of New View box, and then select one of the following options:47

  4. On the View tab, click View Settings to open the Advanced View Settings dialog box, as shown in Figure 26-2.

  5. Use the options provided in the Advanced View Settings dialog box to customize the view.

  6. After you’ve modified the settings as needed, click OK to close the Customize View dialog box and apply the view changes.

You can create an Outlook 2010 view from scratch if the view you want doesn’t have much in common with any of the existing views. For example, perhaps you want to create an Inbox view that displays your messages as icons rather than headers, as shown in Figure 26-3. You can’t modify a standard message view to display messages as icons, so you need to create the view from scratch.

The process for creating a view from scratch is much like the process of modifying an existing view. When you create a new view, however, you have additional options for specifying the view.

Follow these steps to create a view from scratch:

  1. Open the folder or folder type for which you want to create a custom view.

  2. Click the View tab and then click Change View, Manage Views to open the Manage All Views dialog box.

  3. Click New to open the Create A New View dialog box, shown in Figure 26-4.

  4. In the Name Of New View box, type a name for your new view.

  5. In the Type Of View list, select the type of view you want to create, as follows:

  6. In the Can Be Used On area, select an option as described in the preceding section, and then click OK. The Advanced View Settings dialog box opens.

  7. Customize the view as needed, and then click OK.

  8. Click Apply View to apply the view, or click Close to close the dialog box without applying the view.

Outlook 2010 gives you considerable control over the appearance and contents of a view. When you define a new view or modify an existing view, you end up in the Advanced View Settings dialog box, shown in Figure 26-2. To open this dialog box, click the View tab and click View Settings in the Current View group.

The options available in the Advanced View Settings dialog box change according to the folder selected. For example, the options for the Contacts folder differ in some respects from the options for the Inbox. The same general concepts hold true for each type of folder, however. The following sections explain the various ways that you can use these dialog box options to customize a view.

In most cases, clicking Columns in the Advanced View Settings dialog box opens the Show Columns dialog box, similar to the one shown in Figure 26-6, in which you can select the columns that you want to include in the view. (Exceptions to this behavior are discussed later in the section.) For example, you might use the dialog box to add the Cc or Sensitivity column to the view.

Adding columns in the Show Columns dialog box is easy. The available columns (those not already in the view) appear in the list on the left, and the columns already displayed appear in the list on the right. Select a column in the Available Columns list, and then click Add to add it to the view. To remove a column from the view, select the field in the Show These Columns In This Order list, and then click Remove. Use the Move Up and Move Down buttons to rearrange the order in which the columns are displayed in the view.

In some cases, clicking Columns in the Advanced View Settings dialog box opens a Date/Time Fields dialog box similar to the one shown in Figure 26-7. This occurs when you’re working with a view that shows time duration, such as Day/Week/Month view in the Calendar folder or By Type view in the Journal folder—in effect, nontable views that show time duration graphically.

You use the Date/Time Fields dialog box to specify the fields that Outlook 2010 will use to show item duration in the view. The default settings vary but are typically either Start and End or Start Date and Due Date. As an example, you might use the Date/Time Fields dialog box to change the Task Timeline view in the Tasks folder to show the Date Completed field for the task’s end rather than the Due Date field.

Sometimes it’s helpful to be able to group items in an Outlook 2010 folder based on specific data fields. For example, you might want to group tasks by owner so that you can see at a glance the tasks assigned to specific people. Perhaps you want to organize contacts by country or region. In these and similar cases, you can modify an existing view or create a new one to organize the view based on the most pertinent data. To group data in a view, click Group By in the Advanced View Settings dialog box to open the Group By dialog box, shown in Figure 26-8.

Follow these steps to group data in a view:

Sorting data in a view is different from grouping data. For example, you might group the Tasks folder by owner. Each group in the view then shows the tasks assigned to a particular person. You can then sort the data within the group as needed. For example, you might sort the tasks based first on due date and then on subject. Figure 26-9 shows the Tasks folder grouped by owner and sorted by due date.

Sorting doesn’t rely on grouping—you can sort a view whether or not it is grouped. For example, you might sort the Inbox based on the Received column to show messages in the order in which you received them.

To create a sort order when you customize or define a view, click Sort in the Advanced View Settings dialog box to open the Sort dialog box, shown in Figure 26-10.

To configure sorting in the Sort dialog box, follow these steps:

In Outlook 2010, filtering a view is an extremely powerful feature that gives you considerable control over the data displayed in a given view. For example, you might have hundreds of messages in your Inbox and need to filter the view to show only those messages from a particular sender. You could simply sort the Inbox by the From field and scan the list of messages, but you might want to refine the search a little, perhaps viewing only messages from a specific sender that have an attachment and were sent within the previous week. Filters allow you to do just that.

To configure a filter, click Filter in the Advanced View Settings dialog box to open the Filter dialog box, shown in Figure 26-11. This multi-tabbed dialog box lets you specify multiple conditions to define which items will appear in the view.

Note that the first tab in the Filter dialog box varies according to the current folder type. For a contacts folder, for example, the first tab is labeled Contacts and offers options for creating filter conditions that apply to contacts. For a message folder, the first tab is labeled Messages and provides options for creating filter conditions specific to messages.

The various tabs in the Filter dialog box include a broad range of options that let you specify multiple conditions for the filter. You can use conditions from more than one tab. For example, you might enter words to search for and a sender on the Messages tab, select categories on the More Choices tab, and specify a particular field and value on the Advanced tab.

Click Conditional Formatting in the Advanced View Settings dialog box to display the Conditional Formatting dialog box, similar to the one shown in Figure 26-12. This dialog box lets you create rules that cause Outlook 2010 to format data in the view automatically based on the criteria that you specify. For example, you might create an automatic conditional formatting rule that has Outlook 2010 display in blue all tasks that you own and display all other tasks in black. Or perhaps you may create a rule to display in green all contacts from a specific company.

As you’re working in the Conditional Formatting dialog box, keep in mind that you can’t create task-oriented rules, as you can with the Rules Wizard. For example, you can’t create a rule in this dialog box that moves messages from one folder to another. The rules you create in the Conditional Formatting dialog box control only the appearance (color, font, and font styles) of data in the view.

You can’t modify the conditions for predefined rules, but you can specify the font characteristics to use for the rule. You can also create your own rules and change the order in which rules are applied to achieve the results you need.

To set up a one formatting rule for text, follow these steps:

Many users work in Outlook 2010 and never print any of the items that they store in the program. For other users, however, the ability to print from Outlook 2010 is important. For example, if you use a hard-copy day planner rather than a notebook computer or a Personal Digital Assistant (PDA) to keep track of your daily schedule, you might prepare the schedule in Outlook 2010 and then print it for insertion in the day planner.

This section examines the options and methods for printing your Outlook 2010 data. It also explains how to customize the print styles provided by Outlook 2010 to create custom styles that better suit your preferences or needs.

Printing from Outlook 2010 is just as easy as printing from any other application. Simply select the view or item that you want to print, and then choose File, Print. Outlook 2010 displays a Print page similar to the one shown in Figure 26-14. The contents of the page vary according to the type of view from which you’re printing.

From the Settings list, select a print style. For example, select Phone Directory Style for the Contacts folder to print a phone list, or select one of the two booklet styles to print contact entries for a day planner. If you need to fine-tune the print settings, click Print Options to display a Print dialog box similar to the one shown in Figure 26-15.

Click Page Setup and use the Format tab of the Page Setup dialog box to specify the layout, fonts, and other general properties for the job. The options on the Format tab vary from one folder type to another. For example, you can use the Format tab to set the following options, some of which are specific to particular folder types:

Use the Paper tab, shown in Figure 26-16, to configure the page type, size, source, and other properties. For example, in the Type list on the Paper tab, you can select the type of day planner that you use so that Outlook 2010 prints using that style.

Use the Header/Footer tab, shown in Figure 26-17, to specify the items that you want printed in the header and the footer. This tab provides three boxes for the header and three for the footer. The left box specifies items that print on the left side of the page, the middle box specifies items that print in the middle of the page, and the right box specifies items that print on the right side of the page. You can enter text manually or use the buttons near the bottom to insert specific data such as page numbers, the user, the time, and other dynamic data.

After you select the page setup options, you can return to the Print page to preview the document. Click Print Options again; set the printer properties, the number of copies to print, and other general print settings, and then click Print to print or click Preview to preview the document.

Outlook 2010 provides a broad range of print styles, so it’s likely that they will fit most of your needs. When these print styles don’t quite offer what you need or want, however, you can create a custom print style.

You can either modify an existing print style or copy a style and then modify it to incorporate the changes that you need. If you always use the same modifications on a particular print style, you might prefer to simply modify that existing style rather than creating a new one. If you use the default style occasionally but modify its properties for most other print jobs, consider creating a custom print style based on the existing one so that both are available.

Follow these steps to modify or create a new print style:

When you want to print using a particular style, open the view from which you want to print and then choose File, Print. On the Print page, select the style in the Settings list, set other properties as necessary, and then click OK to print.

The existing print styles in Outlook 2010 and the capability to define custom styles accommodate the needs of most users. In some situations, however, these built-in printing features are not enough. With a little custom scripting and Word 2010, however, you can overcome these limitations.

Word 2010 offers almost unlimited print layout capabilities, making it a great tool for laying out almost any type of document. For example, assume that you’re not satisfied with the way Outlook 2010 prints messages from mail folders. When you print a message, the recipient’s name appears in large, bold type at the top of the page, as shown in Figure 26-20. You are likely printing your own messages, so you might want different information—such as the message subject—displayed on the first line.

Although you can make minimal changes to the print layout, such as adding headers or footers, you can’t do much in Outlook 2010 to change the way that most items are printed. You can, however, copy Outlook 2010 items to Word 2010, format the document as needed, and then print it from Word. You might think that moving the data from Outlook 2010 to Word 2010 is a time-consuming task, but you can make it happen in less than a second, provided you create a script to accomplish the task for you.

In this first example, assume that you want to create a specific layout for contacts that prints the contact name in bold, places the contact’s picture in the upper-right corner, and then includes selected contact information such as address, phone, email, and other properties underneath. Figure 26-21 illustrates this custom print layout.

The first step in creating this custom contact style is to create the document layout in Word 2010.

In a nutshell, this means creating a document template that contains a text form field for each contact item that you want included on the printout and then following these steps:

You now have a template that is ready to be filled in by Outlook 2010. The next step is to create a macro in Outlook 2010 that copies the desired information from the current contact item to the form and then prints the form. The following sample macro accomplishes these tasks. However, this sample does not provide extensive error checking, so consider this a starting point for your own macro. For example, you might want to add code that verifies that the current item is a contact item, and if not, displays an error message and exits.

Click the Developer tab, click Macros, choose Macros, type CustomContactPrint in the Macro Name field, and then click Create. Enter the following code:

Sub CustomContactPrint()
    'Set up objects
    Dim strTemplate As String
    Dim objWord As Object
    Dim objDocs As Object
    Dim objApp As Application
    Dim objItem As Object
    Dim objAttach As Object
    Dim numAttach As Integer
    Dim objNS As NameSpace
    Dim mybklist As Object
    Dim x As Integer
    Dim pictureSaved As Boolean
    Dim myShape As Object
    'Dim ContactAddress
    'Create a Word document and current contact item object
    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")
    'Check to ensure Outlook item is selected
    If TypeName(objApp.ActiveInspector) = "Nothing" Then
        MsgBox "Contact not open. Exiting", vbOKOnly + vbInformation, "Outlook Inside
Out"
        Exit Sub
    End If
    Set objItem = objApp.ActiveInspector.CurrentItem
    Set objWord = CreateObject("Word.Application")
    strTemplate = "c:\myMail\CustomContactPrint.dotx
    Set objDocs = objWord.Documents
    objDocs.Add strTemplate
    Set mybklist = objWord.activeDocument.Bookmarks
    'Fill in the form
    objWord.activeDocument.Bookmarks("LastName").Select
    objWord.Selection.TypeText CStr(objItem.LastName)
    objWord.activeDocument.Bookmarks("FirstName").Select
    objWord.Selection.TypeText CStr(objItem.FirstName)
    If objItem.HasPicture = True Then
        Set objAttach = objItem.Attachments
        numAttach = objAttach.Count
        For x = 1 To numAttach
            If objAttach.Item(x).DisplayName = "ContactPicture.jpg" Then
                objAttach.Item(x).SaveAsFile "C:\myMail\" & _
                objAttach.Item(x).DisplayName
                pictureSaved = True
            End If
        Next x
        If pictureSaved = True Then
            objWord.activeDocument.Bookmarks("Picture").Select
            Set myShape = objWord.activeDocument.Shapes.AddPicture("c:\myMail\ContactPicture.jpg", False, True, 432, -25)
            objWord.activeDocument.Shapes(1).Left = 432 - objWord.activeDocument.
 Shapes(1).Width
         End If
     End If
     objWord.activeDocument.Bookmarks("Address1").Select
     objWord.Selection.TypeText CStr(objItem.BusinessAddressStreet)
     objWord.activeDocument.Bookmarks("Address2").Select
     objWord.Selection.TypeText CStr(objItem.BusinessAddressCity)
     objWord.Selection.TypeText ", "
     objWord.Selection.TypeText CStr(objItem.BusinessAddressState)
     objWord.Selection.TypeText " "
     objWord.Selection.TypeText CStr(objItem.BusinessAddressPostalCode)
     objWord.activeDocument.Bookmarks("Birthday").Select
     objWord.Selection.TypeText CStr(objItem.Birthday)
     objWord.activeDocument.Bookmarks("Spouse").Select
     objWord.Selection.TypeText CStr(objItem.Spouse)
     objWord.activeDocument.Bookmarks("Phone1").Select
     objWord.Selection.TypeText CStr(objItem.BusinessTelephoneNumber)
     objWord.activeDocument.Bookmarks("WebPage").Select
     objWord.Selection.TypeText CStr(objItem.BusinessHomePage)
     objWord.activeDocument.Bookmarks("Email1").Select
     objWord.Selection.TypeText CStr(objItem.Email1Address)
     'Print and exit
     objWord.PrintOut Background:=True

    'Process other system events until printing is finished
    While objWord.BackgroundPrintingStatus
        DoEvents
    Wend
    objWord.Quit SaveChanges:=wdvbaDoNotSaveChanges
    Set objApp = Nothing
    Set objNS = Nothing
    Set objItem = Nothing
    Set objWord = Nothing
    Set objDocs = Nothing
    Set mybklist = Nothing
End Sub

If you examine this macro code, you’ll see that it uses named bookmarks to locate the position in the document where each contact element will be inserted. Also, notice that the lines in the macro that insert specific contact items reference those items by their Outlook 2010 object model names, such as Email1Address, BusinessTelephoneNumber, BusinessHomePage, and so on. If you want to modify this macro to insert other contact items, you’ll need to know the item names. To view contact item properties, click Visual Basic on the Developer tab in the Outlook ribbon, and then choose Help, Microsoft Visual Basic Help. Select Outlook Object Model Reference, and then click ContactItem Object. Click the Properties link, and then scroll through the list of properties to locate the one that you need.

This macro also determines whether the contact has a picture associated with it. If so, the macro cycles through the attachments to locate the picture (which is always named ContactPicture.jpg) and saves it to disk. The macro then inserts the picture in the Word 2010 document. Although ContactPicture.jpg is always the first attachment, regardless of the order in which items are attached or their names, this macro checks each attachment anyway to accommodate future changes in Outlook 2010 regarding picture attachments.

To run the macro and print a contact in this format, in the Contacts folder, open the contact that you want to print. On the Developer tab, in the Code group, select Macros. (If you have not added the Developer tab to the ribbon, press Alt+F8.) Click the Macros button and choose the Project1.CustomContactPrint macro. The macro will run and print the open contact on the default printer.

You can use a method similar to the one in the preceding section to print messages from Outlook 2010 using Word 2010. For example, assume that you want to print email messages with the subject in large, bold type at the top of the page and with other message content printed below that. Figure 26-23 shows a sample form in Word 2010. Use the same general steps detailed in the preceding section to create a Word 2010 template that contains the form text fields and bookmarks needed to hold the message items.

After you create the document template in Word 2010 and save it, open the Microsoft Visual Basic Editor and create the following macro:

Sub CustomMessagePrint()
    'Set up objects
    Dim strTemplate As String
    Dim objWord As Object
    Dim objDocs As Object
    Dim objApp As Application
    Dim objItem As Object
    Dim objNS As NameSpace
    Dim mybklist As Object
    'Create a Word document and current message item object
    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")
    'Check to ensure Outlook item is selected
    If TypeName(objApp.ActiveInspector) = "Nothing" Then
        MsgBox "Message not open. Exiting", vbOKOnly + vbInformation, "Outlook Inside
Out"
        Exit Sub
    End If
    Set objItem = objApp.ActiveInspector.CurrentItem
    Set objWord = CreateObject("Word.Application")
    strTemplate = "c:\myMail\prnmsg.dotx"
    Set objDocs = objWord.Documents
    objDocs.Add strTemplate
    Set mybklist = objWord.activeDocument.Bookmarks
    'Fill in the form
    objWord.activeDocument.Bookmarks("Title").Select
    objWord.Selection.TypeText CStr(objItem.Subject)
    objWord.activeDocument.Bookmarks("From").Select
    objWord.Selection.TypeText CStr(objItem.SenderName)
    objWord.activeDocument.Bookmarks("Sent").Select
    objWord.Selection.TypeText CStr(objItem.SentOn)
    objWord.activeDocument.Bookmarks("Received").Select
    objWord.Selection.TypeText CStr(objItem.ReceivedTime)
    objWord.activeDocument.Bookmarks("To").Select
    objWord.Selection.TypeText CStr(objItem.To)
    objWord.activeDocument.Bookmarks("Cc").Select
    objWord.Selection.TypeText CStr(objItem.CC)
    objWord.activeDocument.Bookmarks("Subject").Select
    objWord.Selection.TypeText CStr(objItem.Subject)
    objWord.activeDocument.Bookmarks("Body").Select
    objWord.Selection.TypeText CStr(objItem.Body)
    'Print and exit

    objWord.PrintOut Background:=True
    'Process other system events until printing is finished
    While objWord.BackgroundPrintingStatus
        DoEvents
    Wend
    objWord.Quit SaveChanges:=wdvbaDoNotSaveChanges
End Sub

As with the CustomContactPrint macro, you can customize this macro and document template to accommodate different or additional message fields as needed.

Microsoft Excel 2010 is another solution to custom printing requirements, particularly for Outlook 2010 table views. For example, assume that you want to print all your Outlook 2010 contacts but you want to arrange them in a different order from what the Table style offers in Outlook 2010 and use different formatting for some of the columns. The solution is simple: Copy the contacts to Excel 2010, format and rearrange as needed, and print by following these steps: