Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Cincinnati, Ohio
    Thanked 0 Times in 0 Posts
    I am trying to send information from the current form to an MS Word template using the following I found in the book Mastering MS Access 2003.

    I get an error on createwordobj "sub or function not defined". If objdocument is being defined as the word document, how should I define createwordobj?

    Private Sub cmdSendLetter_Click()

    Dim objdocument As Word.Document

    'Launch word
    If createwordobj() Then

    'Make word visible
    gobjword.Visible = True

    'Point document object at a new document based on the template
    Set objdocument = gobjword.Documents.add_(CurrentProject.Path & "\")

    'Populate bookmarks
    With objdocument.bookmarks
    .Item("First").range.Text = Nz(Me.First)
    .Item("Last").range.Text = Nz(Me.Last)
    .Item("Address1").range.Text = Nz(MeAddress_1)
    .Item("Patients_City").range.Text = Nz(Me.Patients_City)
    .Item("Patients_State").range.Text = Nz(Me.Patients_State)
    .Item("Zip_Code").range.Text = Nz(Me.Zip_Code)

    End With
    End If
    End Sub

    THank you for your help!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts
    CreateWordObj must be a function that should also be listed in the book; you should copy it into a module in your database.

    The function creates a Word.Application object and assigns it to a global variable gobjWord; you should declare this variable at the top of the module:

    Public gobjWord As Word.Application

    See the book for details.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts