A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Problem getting Outlook custom form to print to Word



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 22nd 07, 11:36 PM posted to microsoft.public.outlook.program_forms
Duane Nutley
external usenet poster
 
Posts: 9
Default Problem getting Outlook custom form to print to Word

I hope someone can help with the problem I am having as it is frustrating me
quite a bit.

I have been asked to create some Outlook form templates for a company and
that is easy. The hard bit is that they want it to print the way it looks in
the form. After browsing this forum I found the Office Article 290775 (link -
http://support.microsoft.com/default...n-us%3bQ290775 ) which was quite handy and worked for one form.

I copied/pasted the code from the one form template that worked into a new
one, changed the fields, etc and when I go to print the form I get the
following error message - Object variable not set 'strVacancyRef', which is
the first field on the form.

My VBA skills are limited as I have not worked a lot in VBA, I can fumble my
way through it, but do not understand what I have done wrong as I cant see
any difference between the code that is written, and the example provided in
the article.

I have copied the code below if that helps.

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:\Outlook Templates\Permanent
Placement Details Form.oft")

'Set the first bookmark
strVacancyRef = Item.UserProperties.Find("RefNo")
oDoc.FormFields ("Text1").Result = strVacancyRef

'Set the second bookmark
strClient = Item.UserProperties.Find("Client")
oDoc.FormFields ("Text2").Result = strClient

'Set the third bookmark
strAddress1 = Item.UserProperties.Find("Address1")
oDoc.FormFields ("Text3").Result = strAddress1

'Set the fourth bookmark
strAddress2 = Item.UserProperties.Find("Address2")
oDoc.FormFields ("Text4").Result = strAddress2

'Set the fifth bookmark
strAddress3 = Item.UserProperties.Find("Address3")
oDoc.FormFields ("Text5").Result = strAddress3

'Set the sixth bookmark
strAddress4 = Item.UserProperties.Find("Address4")
oDoc.FormFields ("Text6").Result = strAddress4

'Set the seventh bookmark
strAddress5 = Item.UserProperties.Find("Address5")
oDoc.FormFields ("Text7").Result = strAddress5

'Set the eighth bookmark
strContact = Item.UserProperties.Find("Cont")
oDoc.FormFields ("Text8").Result = strContact

'Set the ninth bookmark
strClientContactNo = Item.UserProperties.Find("ContNo")
oDoc.FormFields ("Text9").Result = strClientContactNo

'Set the tenth bookmark
strCandidateName = Item.UserProperties.Find("Candidate")
oDoc.FormFields ("Text10").Result = strCandidateName

'Set the eleventh bookmark
strPositionTitle = Item.UserProperties.Find("Position")
oDoc.FormFields ("Text11").Result = strPositionTitle

'Set the twelth bookmark
strDatePlaced = Item.UserProperties.Find("DatePl")
oDoc.FormFields ("Text12").Result = strDatePlaced

'Set the thirteenth bookmark
strCommence = Item.UserProperties.Find("CommDate")
oDoc.FormFields ("Text13").Result = strCommence

'Set the fourteenth bookmark
strBaseSalary = Item.UserProperties.Find("Salary")
oDoc.FormFields ("Text14").Result = strBaseSalary

'Set the fifteenth bookmark
strMotor = Item.UserProperties.Find("MotorVehicle")
oDoc.FormFields ("Text15").Result = strMotor

'Set the sixteenth bookmark
strOther = Item.UserProperties.Find("Other")
oDoc.FormFields ("Text16").Result = strOther

'Set the seventeenth bookmark
strTotal = Item.UserProperties.Find("Total")
oDoc.FormFields ("Text17").Result = strTotal

'Set the eighteenth bookmark
strTeamSplit = Item.UserProperties.Find("TeamSplit")
oDoc.FormFields ("Text18").Result = strTeamSplit

'Set the ninteenth bookmark
strVacancyNo = Item.UserProperties.Find("VacNo")
oDoc.FormFields ("Text19").Result = strVacancyNo

'Set the twentith bookmark
strNarration = Item.UserProperties.Find("Narration")
oDoc.FormFields ("Text20").Result = strNarration

'Set the twentyfirst bookmark
strPaymentTerms = Item.UserProperties.Find("PayTerms")
oDoc.FormFields ("Text21").Result = strPaymentTerms

'Set the twentysecond bookmark
strDueDate = Item.UserProperties.Find("InvoiceDate")
oDoc.FormFields ("Text22").Result = strDueDate

'Set the twentythird bookmark
strSuperannuation = Item.UserProperties.Find("Super")
oDoc.FormFields ("Text23").Result = strSuperannuation

'Set the twentyfourth bookmark
strFee = Item.UserProperties.Find("Fee")
oDoc.FormFields ("Text24").Result = strFee

'Set the twentyfive bookmark
strFeeTotal = Item.UserProperties.Find("FeeTotal")
oDoc.FormFields ("Text25").Result = strFeeTotal

'Set the twentysix bookmark
strGST = Item.UserProperties.Find("GST")
oDoc.FormFields ("Text26").Result = strGST

'Set the twentyseven bookmark
strGSTTotal = Item.UserProperties.Find("GSTTotal")
oDoc.FormFields ("Text27").Result = strGSTTotal

'Set the twentyeight bookmark
strInvoiceValue = Item.UserProperties.Find("InvoiceValue")
oDoc.FormFields ("Text28").Result = strInvoiceValue

'Set the twentynine bookmark
strTeam = Item.UserProperties.Find("Team")
oDoc.FormFields ("Text29").Result = strTeam

'Set the thirty bookmark
strGifts = Item.UserProperties.Find("Gifts")
oDoc.FormFields ("Text30").Result = strGifts

'Set the thirtyone bookmark
strComments = Item.UserProperties.Find("_DocSiteControl1")
oDoc.FormFields ("Text31").Result = strComments

'Set the thirtysecond bookmark
strTo = Item.UserProperties.Find("To")
oDoc.FormFields ("Text32").Result = strTo

'Set the thirtythird bookmark
chkFee = Item.UserProperties.Find("FeeAckn")
oDoc.FormFields ("Check1").Result = chkFee

'Set the thirtyfourth bookmark
chkDates = Item.UserProperties.Find("FollowUp")
oDoc.FormFields ("Check2").Result = chkDates

'Set the thirtyfifth bookmark
chkVoyager = Item.UserProperties.Find("Voyager")
oDoc.FormFields ("Check3").Result = chkVoyager

'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 do not 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
  #2  
Old July 23rd 07, 12:18 AM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Problem getting Outlook custom form to print to Word

The symptoms suggest that there is no custom field on the Outlook form named RefNo. Check the names of the fields in the form -- on the All Fields page, under User-defined Fields in This Item.

Also note that this statement could be a problem:

Set oDoc = oWordApp.Documents.Add ("C:\Outlook Templates\Permanent
Placement Details Form.oft")

An .oft file is an Outlook template, not a Word template. A Word template would be saved as an .dot file. And you shouldn't have a space after Documents.Add. Your statements that use the CreateObject and FormFields also have extraneous spaces.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duane Nutley" wrote in message ...
I hope someone can help with the problem I am having as it is frustrating me
quite a bit.

I have been asked to create some Outlook form templates for a company and
that is easy. The hard bit is that they want it to print the way it looks in
the form. After browsing this forum I found the Office Article 290775 (link -
http://support.microsoft.com/default...n-us%3bQ290775 ) which was quite handy and worked for one form.

I copied/pasted the code from the one form template that worked into a new
one, changed the fields, etc and when I go to print the form I get the
following error message - Object variable not set 'strVacancyRef', which is
the first field on the form.

My VBA skills are limited as I have not worked a lot in VBA, I can fumble my
way through it, but do not understand what I have done wrong as I cant see
any difference between the code that is written, and the example provided in
the article.

I have copied the code below if that helps.

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:\Outlook Templates\Permanent
Placement Details Form.oft")

'Set the first bookmark
strVacancyRef = Item.UserProperties.Find("RefNo")
oDoc.FormFields ("Text1").Result = strVacancyRef


  #3  
Old July 23rd 07, 08:22 AM posted to microsoft.public.outlook.program_forms
Duane Nutley
external usenet poster
 
Posts: 9
Default Problem getting Outlook custom form to print to Word

Sue,
Thank you for your reply! I cant believe I told it to look at the oft, not
the dot file.

As to the User defined fields, the fields it is looking for are the ones
that are named by right clicking on each field on the form and going to
Properties and putting in a name there. But I will look at what they are
named in the User Defined Fields section of the form.

"Sue Mosher [MVP-Outlook]" wrote:

The symptoms suggest that there is no custom field on the Outlook form named RefNo. Check the names of the fields in the form -- on the All Fields page, under User-defined Fields in This Item.

Also note that this statement could be a problem:

Set oDoc = oWordApp.Documents.Add ("C:\Outlook Templates\Permanent
Placement Details Form.oft")

An .oft file is an Outlook template, not a Word template. A Word template would be saved as an .dot file. And you shouldn't have a space after Documents.Add. Your statements that use the CreateObject and FormFields also have extraneous spaces.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duane Nutley" wrote in message ...
I hope someone can help with the problem I am having as it is frustrating me
quite a bit.

I have been asked to create some Outlook form templates for a company and
that is easy. The hard bit is that they want it to print the way it looks in
the form. After browsing this forum I found the Office Article 290775 (link -
http://support.microsoft.com/default...n-us%3bQ290775 ) which was quite handy and worked for one form.

I copied/pasted the code from the one form template that worked into a new
one, changed the fields, etc and when I go to print the form I get the
following error message - Object variable not set 'strVacancyRef', which is
the first field on the form.

My VBA skills are limited as I have not worked a lot in VBA, I can fumble my
way through it, but do not understand what I have done wrong as I cant see
any difference between the code that is written, and the example provided in
the article.

I have copied the code below if that helps.

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:\Outlook Templates\Permanent
Placement Details Form.oft")

'Set the first bookmark
strVacancyRef = Item.UserProperties.Find("RefNo")
oDoc.FormFields ("Text1").Result = strVacancyRef



  #4  
Old July 25th 07, 04:42 AM posted to microsoft.public.outlook.program_forms
Duane Nutley
external usenet poster
 
Posts: 9
Default Problem getting Outlook custom form to print to Word

Sue, All is working fine and it was mainly that it was looking for the oft
file not the dot template that was causing the issue.

However I have now noticed that 3 checkboxes on the Outlook form are not
filling in their equivalent Word tickboxes. I had a look at some other posts
about checkboxes and I am not sure what is causing the fault.

The field is called something like Fee Acknowledged and is a Yes/No Field.
When I rightclick on the control on the form, in the Value tab, it says it is
looking for the field Fee Acknowledge, is a Yes/No field and will display the
Icon. Is there anything else I need to change to get it to work?

Also I used the suggestion of oDoc.FormField("Check1") = user.itemproperties
code (sorry I cant remember the actual code that was used, but it was
different to what I used) and an Error about Value Mismatch came up. Now I
dont understand why that would occur as it has been told to look for a Word
form field called Check1, that is a tickbox, and on the Outlook form it is a
Yes/No field.


My last problem (and a new one I have never seen before), I can create the
form, have it print out (minus the tickboxes being selected) and send it to
someone all fine. But in Outlook Inbox, in the preview pane it says it needs
to be opened to view the contents (which I understand and am ok with). BUT
when I double click to open the email, an error message occurs, stating that
a value parameter is not valid and it will not open the email.
I have never seen this problem before and wonder if you know what might be
causing it? It has only come up so far when I tested the form by using the
Run this Form command under Form menu, while in the Design mode of the
Outlook form.

Again thank you for taking the time to read this and offer suggestion.
Duane

"Duane Nutley" wrote:

Sue,
Thank you for your reply! I cant believe I told it to look at the oft, not
the dot file.

As to the User defined fields, the fields it is looking for are the ones
that are named by right clicking on each field on the form and going to
Properties and putting in a name there. But I will look at what they are
named in the User Defined Fields section of the form.

"Sue Mosher [MVP-Outlook]" wrote:

The symptoms suggest that there is no custom field on the Outlook form named RefNo. Check the names of the fields in the form -- on the All Fields page, under User-defined Fields in This Item.

Also note that this statement could be a problem:

Set oDoc = oWordApp.Documents.Add ("C:\Outlook Templates\Permanent
Placement Details Form.oft")

An .oft file is an Outlook template, not a Word template. A Word template would be saved as an .dot file. And you shouldn't have a space after Documents.Add. Your statements that use the CreateObject and FormFields also have extraneous spaces.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duane Nutley" wrote in message ...
I hope someone can help with the problem I am having as it is frustrating me
quite a bit.

I have been asked to create some Outlook form templates for a company and
that is easy. The hard bit is that they want it to print the way it looks in
the form. After browsing this forum I found the Office Article 290775 (link -
http://support.microsoft.com/default...n-us%3bQ290775 ) which was quite handy and worked for one form.

I copied/pasted the code from the one form template that worked into a new
one, changed the fields, etc and when I go to print the form I get the
following error message - Object variable not set 'strVacancyRef', which is
the first field on the form.

My VBA skills are limited as I have not worked a lot in VBA, I can fumble my
way through it, but do not understand what I have done wrong as I cant see
any difference between the code that is written, and the example provided in
the article.

I have copied the code below if that helps.

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:\Outlook Templates\Permanent
Placement Details Form.oft")

'Set the first bookmark
strVacancyRef = Item.UserProperties.Find("RefNo")
oDoc.FormFields ("Text1").Result = strVacancyRef



  #5  
Old July 25th 07, 12:14 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Problem getting Outlook custom form to print to Word

Regarding the checkbox, the correct syntax would be:

oDoc.FormField("Check1").CheckBox.Value = Item.UserProperties('your yes/no field")

The appearance in the reading pane is perfectly normal for a custom form that has code behind it. The error message could be due to code in the Item_Open event hander, which doesn't run until the user opens the item. The exact text of the error message would probably be helpful.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duane Nutley" wrote in message ...

However I have now noticed that 3 checkboxes on the Outlook form are not
filling in their equivalent Word tickboxes. I had a look at some other posts
about checkboxes and I am not sure what is causing the fault.

The field is called something like Fee Acknowledged and is a Yes/No Field.
When I rightclick on the control on the form, in the Value tab, it says it is
looking for the field Fee Acknowledge, is a Yes/No field and will display the
Icon. Is there anything else I need to change to get it to work?

Also I used the suggestion of oDoc.FormField("Check1") = user.itemproperties
code (sorry I cant remember the actual code that was used, but it was
different to what I used) and an Error about Value Mismatch came up. Now I
dont understand why that would occur as it has been told to look for a Word
form field called Check1, that is a tickbox, and on the Outlook form it is a
Yes/No field.

My last problem (and a new one I have never seen before), I can create the
form, have it print out (minus the tickboxes being selected) and send it to
someone all fine. But in Outlook Inbox, in the preview pane it says it needs
to be opened to view the contents (which I understand and am ok with). BUT
when I double click to open the email, an error message occurs, stating that
a value parameter is not valid and it will not open the email.
I have never seen this problem before and wonder if you know what might be
causing it? It has only come up so far when I tested the form by using the
Run this Form command under Form menu, while in the Design mode of the
Outlook form.


  #6  
Old July 30th 07, 12:06 AM posted to microsoft.public.outlook.program_forms
Duane Nutley
external usenet poster
 
Posts: 9
Default Problem getting Outlook custom form to print to Word

Sue,
The check boxes work! Of course only after making it oDoc.FormFields, not
FormField. So that one is now off the list.

The error when attempting to open the form once it has been received is as
follows:

"Can't open this item. Could not complete the operation. One or more
parameter values are not valid".

I am wondering if this is because I deleted the message body field. I could
not find the VBA code to get information from an email body (I thought it was
Item.Message), so I deleted the message body field and inserted a text field.

Something slightly related to this - Why is it that some people cannot view
an Outlook form correctly? Instead it comes up as a normal email message.
The forms I have created, one gentleman at the company, when he opens the
Outlook template from his computer, all he sees is a normal email, not the
form.

Duane


"Sue Mosher [MVP-Outlook]" wrote:

Regarding the checkbox, the correct syntax would be:

oDoc.FormField("Check1").CheckBox.Value = Item.UserProperties('your yes/no field")

The appearance in the reading pane is perfectly normal for a custom form that has code behind it. The error message could be due to code in the Item_Open event hander, which doesn't run until the user opens the item. The exact text of the error message would probably be helpful.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Duane Nutley" wrote in message ...

However I have now noticed that 3 checkboxes on the Outlook form are not
filling in their equivalent Word tickboxes. I had a look at some other posts
about checkboxes and I am not sure what is causing the fault.

The field is called something like Fee Acknowledged and is a Yes/No Field.
When I rightclick on the control on the form, in the Value tab, it says it is
looking for the field Fee Acknowledge, is a Yes/No field and will display the
Icon. Is there anything else I need to change to get it to work?

Also I used the suggestion of oDoc.FormField("Check1") = user.itemproperties
code (sorry I cant remember the actual code that was used, but it was
different to what I used) and an Error about Value Mismatch came up. Now I
dont understand why that would occur as it has been told to look for a Word
form field called Check1, that is a tickbox, and on the Outlook form it is a
Yes/No field.

My last problem (and a new one I have never seen before), I can create the
form, have it print out (minus the tickboxes being selected) and send it to
someone all fine. But in Outlook Inbox, in the preview pane it says it needs
to be opened to view the contents (which I understand and am ok with). BUT
when I double click to open the email, an error message occurs, stating that
a value parameter is not valid and it will not open the email.
I have never seen this problem before and wonder if you know what might be
causing it? It has only come up so far when I tested the form by using the
Run this Form command under Form menu, while in the Design mode of the
Outlook form.



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
choose custom form fields and print in day view sfsc Outlook - Calandaring 1 December 21st 06 12:06 AM
How do I print a custom email form as it looks on the screen? nolatrash Outlook - Using Forms 1 July 26th 06 11:30 PM
Print or save custom form without sender's information andreag Outlook - General Queries 0 May 23rd 06 02:43 PM
Problem Printing Customized Outlook Form using Word Template ajkim001 Outlook - Using Forms 15 April 28th 06 05:28 PM
How do I print a custom form to look like design view layout? trufftwink Outlook - Using Forms 2 March 30th 06 04:58 PM


All times are GMT +1. The time now is 02:09 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright 2004-2025 Outlook Banter.
The comments are property of their posters.