OL98: Outlook Does Not Print Forms as ExpectedID: Q194802
|
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.
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.
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:
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.
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
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
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