OL98: Outlook Does Not Print Forms as Expected (194802)
The information in this article applies to:
This article was previously published under Q194802 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 dialog box. For programmers, the Outlook object model does not provide additional ways of directly changing the print format of a form.
MORE INFORMATIONIMPORTANT: 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 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: - Whether you are using a custom form, or would consider using one to receive additional functionality.
- Whether you need a custom print format, or just want to print the form exactly as it appears on the screen.
- Your programming background. If you are familiar with Visual Basic-type programming, you could develop a solution yourself. If not, you may want to obtain the services of a developer who could provide the solution for you.
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 image from the
clipboard to another program and print it.
To have Microsoft Word 97 print an image of the form, follow these steps: - With the Outlook form currently 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 enable more room for the image to fit on the page.
- On the Edit menu, click Paste.
- Resize the image as appropriate. To do this, click the image once to select it. Click the Format menu, and then click Picture. Click the Size page of Format Picture. On the Size tab, set the Height and Width of the picture.
- To print the document, on the File menu, click Print.
Method 2: Use VBScript To Automate the ALT+PRINT SCREEN MethodMicrosoft 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:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
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 may print it. You must add a Print button to the form.
To create this custom form, follow these steps: - On the Tools menu, point to Forms, and click Design This Form. Click the (P.2) page of the form.
- On the Form menu, click Control Toolbox. Drag a CommandButton control to 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.
- 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
- 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.
- Close and do not save changes to the form.
To Test the Form- On the Actions menu, click New Print Test.
- Press ALT+PRINT SCREEN.
- 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.
To Create the Sample Word Template- Open a new document in Word.
- On the View menu, click Toolbars, and then click Forms.
- 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.
- Click the Protect Form button on the Forms toolbar to protect the template.
- On the File menu, click Save As. Change the Save As Type setting to Word Template, change the Save In setting to C:\, type MyForm as the name of the template, and click Save.
- Close the template.
To Create the Outlook Form- 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.
- 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.
- 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
- On the Tools menu, click Forms, and then click Publish Form. The window should default to storing the contact form in your Contacts folder. Type Send Fields as the Display Name, and then click Publish.
- Close and do not save changes to the form.
To Test the Form- On the Actions menu, click New Send Fields.
- Enter a full name for the contact, and on the Details page of the form, enter a birthday.
- 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. This utility may also work with Outlook 97 and 98. 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
REFERENCES
For more information about creating solutions with Microsoft Outlook 98,
please click the article numbers below to view the articles in the Microsoft Knowledge Base: 180826 OL98: Resources for Custom Forms and Programming
182349 OL98: Questions About Custom Forms and Outlook Solutions
Modification Type: | Major | Last Reviewed: | 5/13/2002 |
---|
Keywords: | kbprb KB194802 |
---|
|