Printing Outlook Form Controls via Word

Not open for further replies.


Outlook version
Outlook 2010 64 bit
Email Account
Howdy all. I've been following advice from various forums but I cannot seem to get it working. The overly simplfied version of what I am doing is as follows:

I have a Label in word called "projectName" who's caption is blank. I have a textbox in Outlook called "projectName". I want to hit the button on the form and send the value in the textbox to that label in word, and then print the word document. If someone could help me correct the line I've made obvious I would appreciate it (also if there's errors below it I'd appreciate the heads up). All I have is textboxes, checkboxes and comboboxes in the form.

Sub printButton_Click() 
Set oWordApp = CreateObject("Word.Application") 
Set FormPage = Item.GetInspector.ModifiedFormPages("Message") 
If oWordApp Is Nothing Then
    MsgBox "Couldn't start Word." 
   MsgBox "Could Start Word."
   Dim oWordApp
   Dim oWordDoc
   Dim bolPrintBackground 
' Open a new document. 
Set oDoc = oWordApp.Documents.Add("C:\Scratchpad\Survey_Request_Form_Print_Template.dotm") 
'Set the first bookmark to the contact's full name. 
'********** THIS LINE IS BORKED **********
   oDoc.FormFields("projectName").Label = CStr(FormPage.Controls("projectName").Text) 
'********** THIS LINE IS BORKED ********** 
   ' Get the current Word setting for background printing.
   bolPrintBackground = oWordApp.Options.PrintBackground 
' Turn background printing off.
   oWordApp.Options.PrintBackground = False 
   ' Print the Word document.
' Restore previous setting.
   oWordApp.Options.PrintBackground = bolPrintBackground 
   ' Close and do not save changes to the document.
   Const wdDoNotSaveChanges = 0
   oDoc.Close wdDoNotSaveChanges 
   ' Close the Word instance.
'Clean up.
   Set oDoc = Nothing
   Set oWordApp = Nothing 
End If 
End Sub
Bump - could really do with help here. Been stalled out on this for a week

Cheers guys
Sorry about that - i was out of town and my helpers aren't very good at helping. :(

I'm not sure if you can insert into label fields, I've only inserted into bookmarks and text fields. Did you try assigning the string to a variable then insert it -
strMyField = CStr(FormPage.Controls("projectName").Text)
oDoc.FormFields("projectName").Label = strMyField
oDoc.FormFields("projectName").Label = strMyField

This line returned a "The requested member of the collection does not exist." Therefore it would seem your uncertainty was well founded! I swapped to Plain Text Controls and it worked wonders.

Thanks for your help :)
Sorry for the triple post. New problem same code.

There is a print button on the form which calls the template. It works on the originating computer, but not on the recieving computer. Hitting "Develop This Form' shows the code correctly sends, and the code has error MsgBoxs which are not popping up. I can post the code if it helps, but it's 8000 characters and therefore exceeds the 4000 character limit on this forum.
Do you have macro security set to low? That is #1 cause of code not working. If the code is running (so its not macro security) , comment out all of the error handlers and run it or step through it to see where it stops.
I'll check tomorrow, I have not changed that setting because I was unaware it existed.

I should point out that I can use the code when running the form with the "Run This Form" option inside "Design This Form". That's how I didn't discover my issue until I sent it for testing
if the code works inside run this firm, it's not macro security. Is the form published or opened from the Choose Form dialog? Because it has script behind it, you need to open it using the Choose Forms dialog or publish it. Outlook will usually popup a warning about this though.
Choose form option was chosen on the test clients.

The button isn't even doing anything; on a different program altogether we had to enable the code to send along it's identity, otherwise the client didn't know the button was actually called printButton etc. In Outlook do we have to alter anything to send definitions of objects?
It seems the form had to be published to each individual clients Form Directory inside outlook in order for my printing code to function.
Correct, it needs published - that is a security feature of outlook. If you use Exchange server it could be published to the organizational forms library, but with other accounts every user needs to publish it.
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T Printing from Outlook is now defaulting to "Shrink to Fit"! Using Outlook 5
S Outlook 2007 printing wrong email address at top of page Using Outlook 8
P Printing PDF attachments of Outlook message attachments Outlook VBA and Custom Forms 2
P printing weekly calendar in Outlook 2013 cuts days of week off Using Outlook 1
G booklet printing in outlook 2007 Using Outlook 1
M Outlook 2013 is printing headers only Using Outlook 4
D Printing Attachments Automatically in Outlook 2010 Using Outlook 1
J outlook printing Using Outlook 2
J Printing Calendar in Outlook 2013 Using Outlook 0
K Printing & Saving Outlook Contacts Using Outlook 3
P Printing Issues in Outlook 2007 Using Outlook 1
E Outlook 2010 network printing problems Using Outlook 4
L Auto printing unread email + attachments in Inbox - Outlook 2010 - (New user) Using Outlook 1
S How to remove tracking from printing - outlook 2010 Using Outlook 4
A Outlook CPAO - Printing Monthly calendar with only all day events or catergory Using Outlook 2
M Outlook 2010 task line printing Using Outlook 1
A outlook printing assistant Help editing template Using Outlook 3
W Calendar Printing with Outlook 2010 (64 bit) Using Outlook 1
J Outlook 2003 - Tasks - Printing Notes Using Outlook 1
R Header not printing in Outlook 2010 Using Outlook 3
P Printing problems with MS Outlook 2000 Using Outlook 1
A Emailing Calendars Created in Outlook Calendar Printing Assistant Using Outlook 3
S Appointment font size when printing only changes Tasks' font Using Outlook 0
A How to use calender printing? Using Outlook 1
M Printing Appointments Using Outlook 1
M Calendar daily Appointments and printing Using Outlook 0
W Automatically open attachments without automatically printing them Using Outlook 0
snissen Printing foreign language messages Using Outlook 1
L printing contacts Using Outlook 1
A How to get rid of Contacts field when printing emails? Using Outlook 0
Diane Poremsky Printing Calendars with Color Categories Using Outlook 0
D VBA macro printing attachments in shared mailbox Outlook VBA and Custom Forms 1
D Printing Contacts Using Outlook 2
C Printing tasks with multiple categories Using Outlook 5
S macro for opening attachments and printing Using Outlook 1
J Printing Mulitple Calendars Outlook VBA and Custom Forms 1
M Calendar Printing Assistant Hangs only on specific Template Using Outlook 2
W Meeting printing background fields Using Outlook 0
K calendar printing Using Outlook 1
B Printing Advanced Search Output Screen Using Outlook 5
S So Disappointed in Calendar Printing Assistant!! Using Outlook 2
F Printing all day events only Using Outlook 3
E Printing Using Outlook 1
C Custom .oft / Printing Issue(s) Using Outlook 1
I Printing Using Outlook 0
E Monthly Style Calendar Printing Using Outlook 6
P Printing calendar (work week) with numerous (i.e. >7) all day events... Using Outlook 3
E Adding Start and End Time to Daily View in Calendar Printing assistant Using Outlook 1
S Printing Selected Date Range in Monthly Style Using Outlook 1
S Does Printing Assistant Work with Windows 8 and Office 10? Using Outlook 1

Similar threads