Open Report in Word

K

KevinCB

Hi

I have created a mail-merged word document, but would like to add a report
onto the end of this if possible.

I know it's possible to create a rtf file in word and do it this way, but
since the report just contains text I just wanted to add it onto the end of
the word document.

I have tried using the following code, to try and add it onto the end of the
document, but it doesn't seem to work.

Dim oMainDoc As Word.Document
Dim oSel As Word.Selection
Dim strBodyText As String
Dim strBookingID As String
Dim sSQL As String

'Start Word
Set oApp = CreateObject("Word.Application")
'Start new main document for the Mail Merge
Set oMainDoc = oApp.Documents.AddstrBodyText = txtLetterstrBookingID =
[Forms]![frmConferencing]![Booking_ID]

With oMainDoc.MailMerge
.MainDocumentType = wdFormLetters
oMainDoc.MailMerge.OpenDataSource _
Name:=stDbFilePath, _
LinkToSource:=True, _
SQLStatement:="SELECT * FROM VwConf_Letter WHERE Booking_ID =" &
strBookingID

Set oSel = oApp.Selection
With .Fields
.Add oSel.Range, "Emp_Name"
oSel.TypeParagraph
.Add oSel.Range, "Addr1"
oSel.TypeParagraph
.Add oSel.Range, "Addr2"
oSel.TypeParagraph
.Add oSel.Range, "Addr3"
oSel.TypeParagraph
.Add oSel.Range, "Addr4"
oSel.TypeParagraph
.Add oSel.Range, "Addr5"
oSel.TypeParagraph
.Add oSel.Range, "Country"
oSel.TypeParagraph
.Add oSel.Range, "PostCode"
oSel.TypeText " "
.Add oSel.Range, "PostCode2"
oSel.TypeParagraph
oSel.TypeParagraph
oSel.InsertDateTime
oSel.TypeParagraph
oSel.TypeParagraph
oSel.TypeText "Dear "
.Add oSel.Range, "Name1"
oSel.TypeText ","
oSel.TypeParagraph
oSel.TypeParagraph

oSel.TypeText strBodyText

DoCmd.OutputTo acOutputReport, "rptConfAdditionalNotes", acFormatRTF,
oMainDoc

End With
End With

With oMainDoc
.MailMerge.Destination = wdSendToNewDocument
.MailMerge.Execute Pause = False
End With

Is it possible for me to do this?
 
T

TedMi

How does your question relate to Access, the database manager? If it doesn't,
I suggest you post it in the Word newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top