Macro to run from a form and save to rtf files

G

Guest

I have a form which I'd like to automatically be able to run a macro which
will create an rtf file for each record and save each one to a file based on
2 fields.

I'm able to to do an output to but then I have to save each one, one by one
and manually name it.

Currently the macro I have does the following. I run it from INVOICE FORM
EMAIL

OPEN REPORT:
Report Name: Invoices
View: Print Preview
Filter Name: Receipt 1
Where Condition: [SaleID]=[Forms]![Invoice From Email]![SaleID]

OUTPUT TO:
Object Type: Report
Object Name: Invoices
Output Type: Rich Text Format
Output File: C:\NETUSER\HH\Invoices\
AutoStart: Yes

CLOSE

I'd like to be able to save all the files as rtf's to C:\NETUSER\HH\Invoices\
and named [INVOICE_DATE]&[FILE_NUM] all at once

Any suggestions?
 
S

Steve Schapel

Shawna,

To do this with a macro is a bit awkward, as it involves cycling through
the records and processing one by one. Still, it can be done. Is your
Invoice From Email form a continuous view form? In any case, I would
suggest basing the report on a query that uses the current record on the
form (is that the purpose of the SaleID?) in the criteria of the query
itself, so you get the correct data every time. You can remove the
OpenReport action from your macro, I don't think it achieves anything at
all. Just put your OutputTo action, plus a second action:
GoToRecord/Next. In the OutputTo action, there should be no problem in
entering the Output File argument like this...
="C:\NETUSER\HH\Invoices\" & [INVOICE_DATE] & [FILE_NUM] & ".rtf"
Name and save this macro.
Then make another macro, using the RunMacro action, and nominate the
first macro in the Macro Name argument. If it happens that you will
always have the same number of reports to send out, just enter that
number in the Repeat Count argument of the macro. Otherwise, leave the
Repeat Count argument blank, and enter something like this in the Repeat
Expression argument...
[FILE_NUM] Is Not Null
So then, it is this second macro that you use to output your RTFs.
 

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