Outlook 2002 does not print forms as expected (290775)



The information in this article applies to:

  • Microsoft Outlook 2002

This article was previously published under Q290775
For a Microsoft Outlook 2000 version of this article, see 230512.
For a Microsoft Outlook 98 version of this article, see 194802.

SYMPTOMS

You want to print a Microsoft Outlook form in a specific format, but there does not appear to be a way to do this.

CAUSE

Outlook can only print forms with the options that are available in the Print window. While you can customize the Print Style settings using the various options Outlook provides in its user interface, you cannot alter the basic way that Outlook prints by using custom Print Styles.

For programmers, the Outlook object model does not provide additional ways of directly changing the print format of a form.

MORE INFORMATION

Important This article requires knowledge of creating custom Outlook forms and using Microsoft Visual Basic Scripting Edition (VBScript). It provides a basic example of how to begin implementing a solution and will most likely require considerable customization to suit a specific need. If you do not have a background in programming and implementing a custom solution, you may wish to seek the assistance of a Solution Provider. For more information about how to contact a Microsoft Solution Provider, click the following article number to view the article in the Microsoft Knowledge Base:

287531 List of resources for custom forms and programming with Outlook 2002

The following methods provide an overview of possible approaches you can use to solve this problem. These approaches should be evaluated based on factors such as:
  • Whether you are using a custom form or would consider using one to enable additional functionality.
  • Whether you need a custom print format or just want to print the form exactly as it appears on the screen.
  • Whether you have an adequate programming background. If you are familiar with Visual Basic-type programming, you could develop a solution. If not, you may want to obtain the services of a developer who can provide the solution.

Method 1: Use ALT+PRINT SCREEN

If you want to print a form as it appears on the screen without developing a solution, you can use the ALT+PRINT SCREEN key sequence to copy the image of the form to the clipboard. You can then paste the contents of the clipboard into another program and print it.

To have Microsoft Word print an image of the form, follow these steps:
  1. With the Outlook form displayed, press ALT+PRINT SCREEN. You will not see or hear anything happen.
  2. Switch to or start Word.
  3. Make sure that you have a new document open. You may want to reduce the margins of the document to allow more room for the image to fit on the page.
  4. On the Edit menu, click Paste.
  5. Resize the image as appropriate:
    1. Click the image once to select it.
    2. On the Format menu, click Picture.
    3. Click the Size page of Format Picture.
    4. On the Size tab, set the Height and Width of the picture.
  6. To print the document, on the File menu, click Print.

Method 2: Use VBScript to automate the ALT+PRINT SCREEN method

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

If you want to print a form as it appears on the screen and would consider using a custom Outlook form that contains custom programming code, you can use Visual Basic Scripting Edition (VBScript) to automate Method 1. The end result will be that you can press ALT+PRINT SCREEN and then click a button on the form to print it. You must add a Print button to the form to do this.

To create the custom form, follow these steps:
  1. On the Tools menu, point to Forms, and then click Design This Form. Click the (P.2) page of the form.
  2. On the Form menu, click Control Toolbox. Drag a CommandButton control onto the (P.2) page of the form. Right-click the control, and then click Properties. On the Display tab, set the Name to cmdPrint and the Caption to Print. Click OK, and then close the Control ToolBox.
  3. On the Form menu, click View Code. Enter the following VBScript code in the Script Editor, and then close the Script Editor.
    Sub cmdPrint_Click()
       Set oWordApp = CreateObject("Word.Application")
       If oWordApp Is Nothing Then
          MsgBox "Couldn't start Word."
       Else
          Dim oWordApp
          Dim oWordDoc
          Dim oBMs
          Dim bolPrintBackground
    
          ' Open a new document.
          Set oDoc = oWordApp.Documents.Add
    
          ' Set a page setup object variable.
          Set oPS = oDoc.PageSetup
    
          ' Reduce the margins to .5" (36 points).
          oPS.TopMargin = 36
          oPS.BottomMargin = 36
          oPS.LeftMargin = 36
          oPS.RightMargin = 36
    
          ' Paste in the screen shot.
          oWordApp.Selection.Paste
    
          ' Center the screen shot.
          Const wdAlignParagraphCenter = 1
          oDoc.Paragraphs(1).Alignment = wdAlignParagraphCenter
    
          ' Get the current Word setting for background printing.
          bolPrintBackground = oWordApp.Options.PrintBackground
    
          ' Turn background printing off.
          oWordApp.Options.PrintBackground = False
    
          ' Print the Word document.
          oDoc.PrintOut
    
          ' Restore previous setting.
          oWordApp.Options.PrintBackground = bolPrintBackground
    
          ' Close and do not save changes to the document.
          Const wdDoNotSaveChanges = 0
          oDoc.Close wdDoNotSaveChanges
    
          ' Close the Word instance.
          oWordApp.Quit
    
          ' Clean up.
          Set oPS = Nothing
          Set oDoc = Nothing
          Set oWordApp = Nothing
       End If
    End Sub
    					
  4. On the Tools menu, point to Forms, and then click Publish Form. The default is to store the Contact form in your Contacts folder. Type Print Test as the Display Name, and then click Publish.
  5. Close and do not save changes to the form.
To test the form, follow these steps:
  1. On the Actions menu, click New Print Test.
  2. Press ALT+PRINT SCREEN.
  3. Click the P.2 page of the form, and then click Print.

Method 3: Generate a custom report

If you want to create a custom printout or to avoid having users press ALT+PRINT SCREEN, you can create a Word template that contains form fields and then have Outlook automatically transfer fields from an Outlook item into the template. With this method, Word will handle all the formatting and printing.

Note You may want to use another program, such as Microsoft Excel, depending on the required format of the printout and your programming ability.

To create the sample Word template, follow these steps:
  1. Open a new document in Word.
  2. On the View menu, point to Toolbars, and then click Forms.
  3. Click the Text Form Field button on the Forms toolbar to insert a form field. Press ENTER two times, and then click the Text Form Field button again to insert a second form field. Note that the form fields have default bookmark names of Text1 and Text2.
  4. Click the Protect Form button on the Forms toolbar to protect the template.
  5. On the File menu, click Save As. Change the Save As Type setting to Document Template. Change the Save In setting to (C:). Type MyForm as the name of the template, and then click Save.
  6. Close the template.
To create the Outlook form, follow these steps:
  1. Open a new Contact form. On the Tools menu, click Forms, and then click Design This Form. Click the (P.2) page of the form.
  2. On the Form menu, click Control Toolbox. Drag a CommandButton control onto the P.2 page of the form. Right-click the control, and then click Properties. On the Display tab, set the Name to cmdPrint and the Caption to Print. Click OK, and then close the Control ToolBox.
  3. On the Form menu, click View Code. Enter the following VBScript code in the Script Editor, and then close the Script Editor.
    Sub cmdPrint_Click()
       Set oWordApp = CreateObject("Word.Application")
       If oWordApp Is Nothing Then
          MsgBox "Couldn't start Word."
       Else
          Dim oWordApp
          Dim oWordDoc
          Dim bolPrintBackground
    
          ' Open a new document.
          Set oDoc = oWordApp.Documents.Add("C:\MyForm.dot")
    
          ' Set the first bookmark to the contact's full name.
          oDoc.FormFields("Text1").Result = CStr(Item.FullName)
    
          ' Set the second bookmark to the contact's birthday.
          oDoc.FormFields("Text2").Result = CStr(Item.Birthday)
    
          ' If the form contains user-defined fields, you can use
          ' the following syntax to transfer the contents of a
          ' user-defined field (FieldName) to Word:
          ' strMyField = Item.UserProperties.Find("FieldName")
          ' oDoc.FormFields("Text3").Result = strMyField
    
          ' Get the current Word setting for background printing.
          bolPrintBackground = oWordApp.Options.PrintBackground
    
          ' Turn background printing off.
          oWordApp.Options.PrintBackground = False
    
          ' Print the Word document.
          oDoc.PrintOut
    
          ' Restore previous setting.
          oWordApp.Options.PrintBackground = bolPrintBackground
    
          ' Close and do not save changes to the document.
          Const wdDoNotSaveChanges = 0
          oDoc.Close wdDoNotSaveChanges
    
          ' Close the Word instance.
          oWordApp.Quit
    
          ' Clean up.
          Set oDoc = Nothing
          Set oWordApp = Nothing
       End If
    End Sub
    					
  4. On the Tools menu, point to Forms, and then click Publish Form. The default is to store the Contact form in your Contacts folder. Type Send Fields as the Display Name, and then click Publish.
  5. Close and do not save changes to the form that was just created.
To test the form, follow these steps:
  1. On the Actions menu, click New Send Fields.
  2. Enter a full name for the contact. On the Details page of the form, enter a birthday.
  3. Click the P.2 page of the form, and then click Print.
The contact's full name and birthday will be printed. You can customize the Word template to suit your needs.

Note This example only supports text field that contain less that 256 characters. If you want to insert more text in each field, you must redesign the solution.

REFERENCES

For more information about available resources and answers to commonly asked questions about Microsoft Outlook solutions, click the following article number to view the article in the Microsoft Knowledge Base:

287530 Frequently asked questions about custom forms and Outlook solutions


Modification Type:MajorLast Reviewed:10/26/2005
Keywords:kbprint kbForms kbprb KB290775