Microsoft KB Archive/230512

= OL2000: Outlook Does Not Print Forms as Expected =

Article ID: 230512

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Outlook 2000 Standard Edition

-



This article was previously published under Q230512





SYMPTOMS
You want to print an Outlook 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. 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 Visual Basic Scripting Edition. It provides a basic example of how to begin implementing a solution and may 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 References section of this article.

The following methods provide an overview of possible approaches you can use to solve this behavior. 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:  With the Outlook form displayed, press ALT+PRINT SCREEN. You may not see or hear anything happen. Switch to or start Word. Make sure 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. On the Edit menu, click Paste. Resize the image as appropriate:  Click the image once to select it.</li> On the Format menu, click Picture.</li> Click the Size page of Format Picture.</li> On the Size tab, set the Height and Width of the picture.</li></ol> </li> To print the document, on the File menu, click Print.</li></ol>

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 a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

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 may 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: <ol> On the Tools menu, point to Forms and then click Design This Form. Click the (P.2) page of the form.</li> 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.</li>  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 </li> 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.</li> Close and do not save changes to the form.</li></ol>

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 may 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, 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 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 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: <ol> 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.</li> 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.</li>  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 </li> 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.</li> Close and do not save changes to the form just created.</li></ol>

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 may be printed. You can customize the Word template to suit your needs.

Method 4: Use the XPrint Control or Add-in
The Microsoft Office 2000 Resource Kit includes a utility called XPrint. It is designed to print Outlook forms as you see them on the screen. In general, it is oriented towards developers or enterprise-level customers. For additional information about this utility and how you can obtain it, please see the following article in the Microsoft Knowledge Base:

238778 OL2000: General Information About the XPrint Control and Add-in

<div class="references_section">