Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

       How did you like this article? Please vote and let us know.          

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Shannal L. Thomas
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath

 

 
 
Many companies that are using Outlook are also struggling with e-form
printing. The following generic script has been used in some to
satisfy some of printing form requirements in my company.

This script uses Word bookmarks and it matches the bookmark names with
the Outlook custom (see contraints) fieldnames.

Pre-requisites:
Outlook 8.02 and up
Word 97 with Service Release 1

Constraints:
1. This code will only work with custom or user defined fields in
Outlook. The code Item.UserProperties.find(strField).value will not
work for Outlook standard fields such as To, Subject, From. To refer
to standard fields also you may change the above statement to
Item.UserProperties.Item(strField) (not tested widely but does seem to
work on most forms) or you can include conditions in the code to match
those fields...

Example

Bookmark("Subject") = Item.Subject
Bookmark("Body") = Item.Body
Bookmark("Birthdate") =
Item.userproperties.find("Birthdate").Value.

2. Outlook field names cannot have period or spaces between the names.
These are not acceptable Word bookmark names.

Trouble shooting version of scripting engine.
This give the version of scripting engine on the workstations.... 3.1 is
pretty current.

Link to OutlookPrintExample.Zip

'Printing function
' - opening a Word template with bookmarks
' - read bookmarks list from template and match with the field names in Outlook form
' - value in form is that populated to the Word doc for auto-printing
' - prompt user for closing Word when printing is done.
' - Save word as C:\deletme.doc before exiting Word.
' 8/21/98 Leng Ho
' 9/16/98 modified to include remove save C:\deletme.doc function
' remove visibility of Word
' correct problem by using Item.UserProperties.find(strField).value
'

Dim strTemplate
Dim objWord
Dim objDocs
Dim PageRange
Dim strField
Dim strField1

Sub cmdBookmarks_Click

Set objWord = CreateObject("Word.Application")

' Put the name of your Word template that contains the bookmarks
strTemplate = "Outlook Printing Example.dot"

' Location of Word template; could be on a shared LAN
strTemplate = "c:\templates\" & strTemplate

Set objDocs = objWord.Documents
objDocs.Add strTemplate
set mybklist = objWord.ActiveDocument.Bookmarks


For counter = 1 to mybklist.count
strField = objWord.ActiveDocument.Bookmarks(counter)
objWord.ActiveDocument.Bookmarks(strField).Select
strField1 = Item.UserProperties.find(strField).value
If strField1 = True then
strField1 = "Yes"
ElseIf strField1 = False then
strField1 = "No "
End If
objWord.Selection.TypeText Cstr(strField1)
Next
objWord.PrintOut Background = True
objWord.Quit(0)

End Sub

Please test it out and let me know.

You can copy the Word template into c:\templates to test this oft file.

The script is generic enough that it would work with most forms. The only restriction is that the Outlook fieldnames cannot have spaces or periods in them. Word cannot support such bookmark names.

Congratulations, your form is just outstanding, I had been looking since long for a solution to print something looking like a REAL form ! Perhaps I have a hint to print Outlook standard fields : for instance, if you want to print the From field, just create a new field in your form, for instance named FromField. Then in the script code, add the following line in the Item_Read function :

Function Item_Read()
Item.UserProperties.Find("FromField").value = item.sendername
End Function

You just have to define a Bookmark called FromField in your Word .dot template. As a result, when a recipient opens the mail, the FromField gets the right value. Then if he clicks your button to print the form, we've got it on the paper !

I think you can print any Outlook standard field with this method. Hope you like it, and best regards,

Benjamin LASTMANN
Network Consultant

Thanks
Leng Ho
Experian

Link to OutlookPrintExample.Zip


Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Pro Exchange. OutlookExchange.Com and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

© Copyright Pro Exchange, Inc., 2006