By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 2,171 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Output Report as .rtf file (Access 2007)

100+
P: 759
Hello !
I use this code to output a report as .rtf file:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "ReportName", "RichTextFormat(*.rtf)", , True
This open the Output To window (identical to Save As window). So is needed to manually brows for a folder where to save the .rtf file.

I wish to avoid this manually step because I save all the time to a certain folder. So I have no need to brows my computer.
Can you help me ?

Thank you !
Jan 15 '12 #1

✓ answered by C CSR

This is from Access help file:
OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile, Encoding, OutputQuality)

As you can see, OutoutFile is the 4th item. Below is the explanation regarding the file>saveas dialog box, and how to avoid it.

OutputFile: A string expression that's the full name, including the path, of the file you want to output the object to. If you leave this argument blank, Access prompts you for an output file name.

Your example is:
OutputTo acOutputReport, "ReportName", "RichTextFormat(*.rtf)", , True.

It looks like you have the filename in the "ObjectName" spot, which is not the filename. ObjectName would like the name of a table, which you would specify in the first spot as "acOutputTable." I think if you wanted the output to go to an internal Access Report you would specify acOutputReport, [existing report],...

Their example is:
DoCmd.OutputTo acOutputTable, "Employees", acFormatRTF, "Employee.rtf", True

You have currently omitted the "Employee.rtf" part from the example.

(Also, if you don't specify the format it will prompt you for that).

Share this Question
Share on Google+
5 Replies


100+
P: 144
Are your parameters in the right order? OutPutFile should be the 4th over, and no prompt should appear if a filename is there. I think it goes into the default database folder unless you specify path & filename. Check your HelpFile on "DoCmd.OutputTo Method."
Jan 15 '12 #2

100+
P: 759
I think that there are in the right order because it work.
My problem is to avoid to open the Output To dialog box because I know the path where I wish to save the .rtf file. It is a relative path to the folder where my database is: MyDatabaseFolder->SubFolder.
Jan 15 '12 #3

100+
P: 144
This is from Access help file:
OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile, Encoding, OutputQuality)

As you can see, OutoutFile is the 4th item. Below is the explanation regarding the file>saveas dialog box, and how to avoid it.

OutputFile: A string expression that's the full name, including the path, of the file you want to output the object to. If you leave this argument blank, Access prompts you for an output file name.

Your example is:
OutputTo acOutputReport, "ReportName", "RichTextFormat(*.rtf)", , True.

It looks like you have the filename in the "ObjectName" spot, which is not the filename. ObjectName would like the name of a table, which you would specify in the first spot as "acOutputTable." I think if you wanted the output to go to an internal Access Report you would specify acOutputReport, [existing report],...

Their example is:
DoCmd.OutputTo acOutputTable, "Employees", acFormatRTF, "Employee.rtf", True

You have currently omitted the "Employee.rtf" part from the example.

(Also, if you don't specify the format it will prompt you for that).
Jan 15 '12 #4

100+
P: 759
Thank you, C CSR !
I don't try yet but this must be the answer.

Thank you again !
Jan 15 '12 #5

NeoPa
Expert Mod 15k+
P: 31,186
Indeed Mihail. I point to consider when coding for calls such as this with so many parameters, is to used Named Parameters. Both harder to make mistakes and more easily understood and supported code. All for a little extra work. Definitely worth it I'd say ;-)
Jan 16 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.