Using WordApp to create a report????

Richard M

Registered User.
Local time
Today, 02:04
Joined
Sep 29, 2010
Messages
75
I am trying to create a Word document using WordApp in a class module. I copied code from an Access program that works. I am using Windows7 and Access 2007.


I am lost.

  1. what Reference do I need to use WordApp?
  2. what call statement do I use. I am using Call CreateChangeOrderReport and it gives me error msg "Compile error: Sub or function not defined. The sub I am calling is Public Sub CreateChangeOrderReport see below code.
  3. What reference do I need for the DAO.database?
  4. And last, I am trying to insert an image. The code I found was on the Internet.
This driving me nuts :banghead:and before I damage myself, I can use some help.

Thanks,
Richard


Code:
 Public Sub CreateChangeOrderReport()
     Dim curDatabase As DAO.Database
    Dim tbl As DAO.Recordset
    Dim strAns As String  'rjm
    Dim strAns2 As String
    Set curDatabase = CurrentDb
    Set Recordset = curDatabase.OpenRecordset("tblChangeOrderforReport", dbOpenSnapshot)
    
    Dim Prospect As String
    Prospect = FilterProspects
      If Prospect = "" Then
        MsgBox "No prospect selected"
    Else
        Recordset.Filter = "[Prospect] = '" & Prospect & "'"
        Set Recordset = Recordset.OpenRecordset
        
        Dim wordApp As Object
        Set wordApp = CreateObject(Class:="Word.Application")
        wordApp.Visible = True
        wordApp.Documents.Add
        Dim bi As Image
                
       wordApp.selection.TypeParagraph()(bi) = Image.FromFile("C:\POCCA\LttrhdTop.bmp")
 

Users who are viewing this thread

Back
Top Bottom