Output Report to RTF

Rusty

Registered User.
Local time
Today, 15:45
Joined
Apr 15, 2004
Messages
207
Hey guys,

I have a btn on a form which runs the code below to output a report to rtf.

Is there any way of specifying a folder I want the .rtf file saved in? At present it just sticks it in the same folder as the database.

Also is there any way of using VBA to specify a file name for the .rtf file. I want to use the term "Invoice Request" and the value in the field called [InvoiceRequestNumber].

Any help would be greatly appreciated - this is the last piece of a large puzzle for a costing and invoicing system I'm designing :o

Thanks,

Rusty
Code:
Private Sub btnPrintInvoiceRequest_Click()
    DoCmd.RunCommand acCmdOutputToRTF

 End Sub
 
try this...

DoCmd.OutputTo acOutputReport,"RptName",acFormatRTF,"file name and directory", etc etc

HTH
 
Thanks for the help Loolaa

I managed to use this with a bit of other code (see below) to launch the report and bring up an option for the user to export to Word (and be able to chose where they save it and under what file name).

Thanks again,

Rusty
:D

Code:
Private Sub btnPrintChequeRequest_Click()
On Error GoTo Err_btnPrintChequeRequest_Click

    DoCmd.OpenReport "rptChequeRequestForm_travel expenses", acViewPreview, , ""

Dim LResponse As Integer
LResponse = MsgBox("Do you want to export the report to Word?", vbYesNo, "Export to Word")

If LResponse = vbYes Then
    DoCmd.OutputTo acOutputReport, "rptChequeRequestForm_travel expenses", acFormatRTF, , , ""
Else
   End If

Exit_btnPrintChequeRequest_Click:
    Exit Sub
    
Err_btnPrintChequeRequest_Click:
        Resume Exit_btnPrintChequeRequest_Click
End Sub
 
Output Question

Greetings.

Rusty [and all], the code you posted regarding the Output of an RTF file to Word is short, simple and to the point. However, I have a question - being the NewBee that I am.

Question. I have been trying to figure out the same thing to Output my report and was advised to use Bookmarks. Your code (as it stands) can output my entire report, in the design that I created, so what is the difference?

Also, you code is designed to Output the entire report, will it work with a Filter? Meaning could it be modified to Output the result of a query? Thanks in advance.
 
Disregard

Disregard. I was able to figure it out.

Basically I allowed the report to preview (thus allowing the rptflag = true query to process), then used an adopted version of the prompt (thanks) and published the end result on the desktop in a temp .rtf file.

All I have to do now is figure out a way to prompt the user if a previous version of the file is open - because you cannot write to an open file.

Thanks none the less.
 

Users who are viewing this thread

Back
Top Bottom