Problem getting Outlook custom form to print to Word

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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.aspx?scid=kb%3ben-us%3bQ290775&ID=kb%3ben-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
.