Re: Problem getting Outlook custom form to print to Word
- From: Duane Nutley <DuaneNutley@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 23 Jul 2007 00:22:02 -0700
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" <DuaneNutley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:28F4E0FE-35D3-43E7-8DA8-7E367448A7E9@xxxxxxxxxxxxxxxx
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
- Follow-Ups:
- Re: Problem getting Outlook custom form to print to Word
- From: Duane Nutley
- Re: Problem getting Outlook custom form to print to Word
- References:
- Problem getting Outlook custom form to print to Word
- From: Duane Nutley
- Re: Problem getting Outlook custom form to print to Word
- From: Sue Mosher [MVP-Outlook]
- Problem getting Outlook custom form to print to Word
- Prev by Date: Re: Problem getting Outlook custom form to print to Word
- Next by Date: Re: Add New Menu items to the Tools Menu in Outlook 2007
- Previous by thread: Re: Problem getting Outlook custom form to print to Word
- Next by thread: Re: Problem getting Outlook custom form to print to Word
- Index(es):
Relevant Pages
|