OL98: Outlook Does Not Print Forms as Expected

ID: Q194802


The information in this article applies to:


SYMPTOMS

You want to print a Microsoft Outlook 98 form in a specific format, but there doesn't appear to be a way to do this.


CAUSE

Outlook can only print forms with the options that are available in the Print window. 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 Visual Basic Scripting Edition. 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 on how to contact a Microsoft Solution Provider, please consult the Knowledge Base article listed in the References section of this article.

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:

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 97 print an image of the form, follow these steps:

  1. With the Outlook form currently displayed, press ALT+PRINT SCREEN. You will not see or hear anything happen.


  2. Switch to or start Word.


  3. Make sure you have a new document open.

    NOTE: 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. Click the Format menu, and then 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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please seethe following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/
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 would be that you can press ALT+PRINT SCREEN and then click a button on the form that will print it. You must add a Print button to the form.

To create this custom form, follow these steps:

  1. On the Tools menu, click Forms and 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 into 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 don't 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, click Forms and then click Publish Form. The window should default to storing the contact form in your contacts folder. Enter "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 click Print.


Method 3: Generate a Custom Report

If you want to create a custom printout, or 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 of 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.

Follow these steps to create the sample Word template:

  1. Open a new document in Word.


  2. On the View menu, click Toolbars and then click Forms.


  3. Click the Text Form Field button on the Forms toolbar to insert a form field. Press ENTER twice 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 Word Template, change the Save In setting to C:\, enter MyForm as the name of the template and click Save.


  6. Close the template.


To create the Outlook form, follow these steps:

  1. Open a new, default 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 into 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 don't 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, click Forms and then click Publish Form. The window should default to storing the contact form in your contacts folder. Enter "Send Fields" as the Display Name and then click Publish.


  5. Close and do not save changes to the form we 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 and on the Details page of the form, enter a birthday.


  3. Click the P.2 page of the form and click Print.


The contact's full name and birthday will be printed. You can customize the Word template to suit your needs.


REFERENCES

For more information about creating solutions with Microsoft Outlook 98, please see the following articles in the Microsoft Knowledge Base:

Q180826 OL98: Resources for Custom Forms and Programming

Q182349 OL98: Questions About Custom Forms and Outlook Solutions

Additional query words: OutSol OutSol98


Keywords          : 
Version           : WINDOWS:
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: July 29, 1999