Code to publish with word

  • Thread starter Thread starter DeVille
  • Start date Start date
D

DeVille

Hi
(Im using access 2002)
I am looking for a line of code to do the same function
as the little button that appears when I open a report on
the tool bar just to the right of the word 'setup', the
button has a large 'W' symbol on it and it
outputs/publishes the open report to MS Word
Here is the code I have on a button(EmailTo) which opens
the report "Email To Report" , the ( ? ) is where I think
the code should go, thanks in advance

Private Sub EmailTo_Click()
On Error GoTo Err_EmailTo_Click

Dim stDocName As String

Me.Refresh

stDocName = "Email To Report"
DoCmd.OpenReport stDocName, acPreview, , "RefId = " &
Me!RefID

( ? )

Exit_EmailTo_Click:
Exit Sub

Err_EmailTo_Click:
MsgBox Err.Description
Resume Exit_EmailTo_Click

End Sub
 
Try

Docmd.OutputTo acReport, "YourReportName", acFormatRTF,
"c:\somedir\somefile.rtf"

The challenge will be that you can not filter your report for the RefID when
you use OutputTo. The work arounds are to either:

1.) Use a form where you input the RefID and then have your report's query
reference that form control as a condition for the RefID field. or

2.) Modify your report's query so that you can pull in parameters set by
code; an example is on our web site in the code and design tips area under
reports.
 
Back
Top