Re: Problem getting Outlook custom form to print to Word

Tech-Archive recommends: Speed Up your PC by fixing your registry



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



.



Relevant Pages

  • Re: Problem getting Outlook custom form to print to Word
    ... The symptoms suggest that there is no custom field on the Outlook form named RefNo. ... following error message - Object variable not set 'strVacancyRef', ... If oWordApp Is Nothing Then ... Dim oWordApp ...
    (microsoft.public.outlook.program_forms)
  • RE: Absolute Beginner and Timer Class
    ... I cant follow where the problem is. ... You cant easily call a timer sub from vb.net as you have to pass the objects ... 'Dim RoundLength As Integer = Form1.RoundLength ... Private CountDownStart ...
    (microsoft.public.dotnet.languages.vb)
  • Defining an R1C1 style dynamic named range using vba
    ... am sure it is just a syntax issue but I cant seem to figure it out. ... Dim WorkRange As Range ... Dim i As Integer, CellCount As Integer ... Set WorkRange = Intersect ...
    (microsoft.public.excel.programming)
  • Re: Absolute Beginner and Timer Class
    ... You cant easily call a timer sub from vb.net as you have to pass the objects ... 'Dim RoundLength As Integer = Form1.RoundLength ... on the various round levels for a Poker Tournament ie ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Whats Wrong With This
    ... Dim c As Range ... Struggling Here need help I cant figure out the & ... I simply need to select the Interior color of cell in col A and the ... interior, offset, and value too ...
    (microsoft.public.excel.programming)