Export report to Word Template

duke_44
2StarLounger
Posts: 115
Joined: 07 Feb 2017, 13:31

Export report to Word Template

Post by duke_44 »

Hello and hope everyone is safe.


On a click of a button I would like to take a report named rptOperator and export it's data to a Word template, also can I set the formatting or would my user have to set each time?

Thank you in advance

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Export report to Word Template

Post by HansV »

Access does not have built-in support for exporting to a Word template. Exporting to a .rtf file is the nearest equivalent.
Best wishes,
Hans

duke_44
2StarLounger
Posts: 115
Joined: 07 Feb 2017, 13:31

Re: Export report to Word Template

Post by duke_44 »

HI Hans, thank you for taking your time to answer/help out here during these times.

Would using .rtf format be recommended? I would like to take specific parts of a record and display in a format that makes it easy for my user to copy/paste out of there. I currently have it exporting to excel for ease of use but I would like to have this report format during export so that the template provides adequate space for any space requirements based on a specific record (like how many findings remain, 1 record could have 0 and the next could have 10).

Chris

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Export report to Word Template

Post by HansV »

Exporting a report to .rtf format preserves the text formatting of the report, but omits graphic elements such as borders and lines.
You can open and edit the .rtf file in Word, either manually or using Word VBA.
I'd try exporting the report and see how much editing it will need to suit your purpose.
Best wishes,
Hans

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Export report to Word Template

Post by Wendell »

A couple of alternatives come to mind:
1) If your users have a PDF printer installed, you could have them print it to a file, and open it in Word. I believe that from version 2013 forward, Word can open PDF files and edit them.

2) If you want to get more elegant, you could do some actual "automation" from Access to Word, populating a Word template and then saving it as a Word document. That requires a fair bit of code, and a good understanding of the Word object model, so it's not something to jump into lightly. If you want more info on that approach, post back.
Wendell
You can't see the view if you don't climb the mountain!

duke_44
2StarLounger
Posts: 115
Joined: 07 Feb 2017, 13:31

Re: Export report to Word Template

Post by duke_44 »

HI Wendall, thank you for you reply, I am not a programmer and HansV has been very patient and helpful - and as always HansV thank you!!

I would prefer to go with the elegant option but my limitations are my skills in VBA lol. After exporting by means of RTF I see there is not a lot of formatting required (as I see it). I would be appreciative of any help with this. Here is a Dropbox link to the WORD doc produced from my Access report. https://www.dropbox.com/s/taqs6x8c5qwc5 ... 0.rtf?dl=0" onclick="window.open(this.href);return false;

I do not have many people using this application so Option 1 is also viable. I would prefer to limit any inputs by my user. Would this require my user to selct "Print", then save into or open with WORD or what does this option look like?

Thank you and stay safe!

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Export report to Word Template

Post by Wendell »

Hi Duke - I agree there is not much formatting required when viewing the RTF version, but as Hans noted earlier, the RTF export removes all graphic elements and generally makes a mess of any subreports you might have. If you have a PDF printer installed, would you try printing a sample using that. (If you don't, Microsoft has such a printer available and you should be able to set it up - it shows up when you select a printer.)

The effort involved in using Automation in Access to generate a Word document from an existing template is considerable, and I don't believe it offers much advantage over printing to PDF. If you want a peek into what is involved, this link gives and example - Word Automation Example. My experience doing that sort of thing (over 10 yrs ago) was that it took many hours to get it to work exactly the way it was supposed to.
Wendell
You can't see the view if you don't climb the mountain!

duke_44
2StarLounger
Posts: 115
Joined: 07 Feb 2017, 13:31

Re: Export report to Word Template

Post by duke_44 »

Thank you Wendell. Now I will sound like a noob but, do you mean take the RTF produced and then select print to PDF or make my "export" button in Access (if there is such a command) do the print to PDF function or have the button print then have my user select print to PDF from the print menu?

I did take the RTF file and then select print to PDF and the formatting as you have seen remains the same.

thanks again!

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Export report to Word Template

Post by Wendell »

No - simply open the report in Access, and then start to print it, but when you get the dialog that asks what printer you want to use, choose "Microsoft Print to PDF" - then it will prompt you for a file name and location. After it is saved, you should be able to click on it and view it in a web browser. It should look exactly like it did in Access. Upload that to this thread and I'll take a look at it.
Wendell
You can't see the view if you don't climb the mountain!

CData
3StarLounger
Posts: 308
Joined: 24 Dec 2015, 16:41

Re: Export report to Word Template

Post by CData »

use the Word Merge feature of Word. It is simple enough - no coding. I think that's what is sought. It is a feature commonly used to generate form letters...
Basically Access' role is to provide the raw data - either query or table. from the Word side you link to it. The instructions to this can be found in the Word forums - look for Word Merge.