There are many ways to export data from Access to Word. Here is one:
Private Sub cmdExportToWord_Click()
Dim objWordApp As Word.Application
Dim objWord As Word.Document
Dim oSel As Word.Selection
DoCmd.OutputTo acOutputReport, "Samples", acFormatRTF, "E:\SamplesReport2.rtf"
Set objWordApp = CreateObject("Word.Application")
Set objWord = objWordApp.Documents.Open("E:\SamplesReport2.rtf")
' Make Word visible.
objWord.Application.Visible = True
Set objWord = Nothing
Set objWordApp = Nothing
End Sub
Also, look here:
http://www.members.shaw.ca/AlbertKal.../msaccess.html
http://www.members.shaw.ca/AlbertKal...rge/page2.html
Ryan---
--
RyGuy--
If the post was helpful, please click the ''Yes'' button to indicate such!
"Kevin B" wrote:
> Hopefully someone has had this issue and can help, but I’m stumped at this
> point.
>
> Both Word and Access are Office 2003 applications.
>
> I’m launching Word from an Access form and the application launches just
> fine, using either GetObject if there’s an active session or CreateObject it
> there isn’t.
>
> If I open a document I do not have any problems, however, when I attempt to
> use a template I get an error 5151 “Word was unable to read this document.
> It may be corrupt.”
>
> If I launch Word manually the template opens just fine, but the code cannot
> seem to do this. I’ve gotten a very functional error routine going, so not
> all is lost, but my original goal ass not been met.
>
> All variables in the code sample below have been explicitly declared and
> when I step through the code using watch the string variables have all the
> correct values.
> ----------------------------------------------------------------------------------
> strPath = DocPath() 'UDF
>
> strTemplate = conAppPath & conDocDot
>
> strDocName = frm.txtPlogID.Value & ".doc"
>
> Set objWord = GetObject(, "Word.Application")
>
> 'intErr is assigned an error number in the error trap
>
> If intErr = 429 Then
> Set objWord = CreateObject("Word.Application")
> End If
>
> With objWord
> .Activate
> Set objDoc = .Documents.Add(Template:=strTemplate)
> .Visible = True
> End With
> With objDoc
> .SaveAs strPath & strDocName
> .Activate
> End With
> objWord.Visible = True
> ----------------------------------------------------------------------------------
>
> Thanks ahead of time, I've been saved more than once by contributors to this
> forum.
> --
> Kevin Backmann