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.
Thanks,
Richard
I am lost.
- what Reference do I need to use WordApp?
- 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.
- What reference do I need for the DAO.database?
- And last, I am trying to insert an image. The code I found was on the Internet.
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")