Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

publish a report with MS word via VBA 1

Status
Not open for further replies.

diepblauw

MIS
Jun 3, 2003
15
CN
In access, I can use toolbar command "publish it with Microsoft Word" to export a report to rtf file. How to do it via VBA code?

Thanks.
 
DoCmd.OutputTo acReport, "NameOfReport", "RichTextFormat(*.rtf)", "C:\WINDOWS\WhereYouWantItStored", True, ""

The true views it afterwards, False wouldn't
 
Sorry ...

DoCmd.OutputTo acReport, "NameOfReport", "RichTextFormat(*.rtf)", "C:\WINDOWS\NameOfWhatYouWantWordDoc.doc", True, ""

Hope this helps
 
Good point evalsthy,

That code would be...

DoCmd.OutputTo acReport, "NameOfReport", acFormatSNP, "C:\WINDOWS\NameOfWhatYouWantWordDoc.snp", False, ""

But although this provides the lines and graphics it is not editable. It is possible to produce an editable word document with images and lines @


It's all to do with saving images as individual files and loading them, take a look. But in your post you did just say rtf format so the first answer should be good enough.

Hope something i've written helps

Cheers

Sam
 
Thanks for all of your replies. But I have to say sorry, I didn't mention my question clearly. Actually, I want to know how to get the name of the current report. For example, I preview report "abc" in access. I can get the file "abc.rtf" via the toolbar command "publish it with Microsoft Word". Then via the VBA code, how to do the same thing?
 
Hi All,

DoCmd.OutputTo acReport, "NameOfReport", "RichTextFormat(*.rtf)", "C:\WINDOWS\WhereYouWantItStored", True, ""

This code doesn't work if you have a hyperlink coded in your report. I mean, it generates the word doc but the hyperlinks seem doesn't work.

Any idea?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top