Discussion Locked

Exporting Acess 97 Reports to Word

0 helpful
12 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have what has become a rather involved database that needs the option of exporting its reports into Word 97. I have played around with object control and don't like the results and would much rather used the built in function on the toolbar (office links). I need for the page header and footer of the report to export into Word's header and footer. This would fix one of my major problems. The other big problem is the data that comes from the report doesn't actually flow like it does in report preview. Sometimes text will end up on other pages and on lines that have nothing to do with that data! If I absolutely must code object control, could someone please assist?

Thank you!
640k

12 replies

by dmiles

1.Choose File from the Access Menu bar
2.Choose Export from the File menu.The Export dialog box will display
3.Choose Word for Windows Merge from the Data destination listbox.Click on OK.
4.Select the data you want to export from the tables box.Click on OK
5.The Expport to File dialog box will dispaly
6.Enter file name and click OK.it will be a .txt file by default
Importing to Word for Windows
Open Word for Windows
Choose File from the Menu Bar
Choose Open from the File menu and type in the name of your file with a .txt extension.Click OK
Your file then should be imported

by sixfourtykilo

Ok this just covered everything I already know. My message clearly states that I have already exported my data (and in report form) to Microsoft Word. The problem with the data is the formatting.. page 1 will overflow onto the next page, page 2 will appear on page 3, text will appear on pages that have nothing to do with each other, etc. These issues are those that need to be corrected. Re-read my question.

640k

by sixfourtykilo

People seem to be confused as to the issue at hand here. I can export my data all day long, but the formatting stinks. Please be sure you understand my question before posting an answer. Thank you.

by peyison

You could try using the Output to Command:

DoCmd.OutputTo acOutputReport, "rptMyReport", acFormatRTF, "MyFile.rtf", False

This will save the file in RTF format, which can then be opened in Word.

If you wanted to, you could save the file asRTF, then open Word and save it as a DOC:

Public Function SaveToWord(asReportName As String, asFileName As String)
Dim WordDoc As Object
Dim WordApp As Object
'--asReportName is the name of the Report to output
'--asFileName is the name of the file to create, without an extension

DoCmd.OutputTo acOutputReport, asReportName, acFormatRTF, asFileName & ".rtf", False

'-- Create instance of Word
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Add
WordApp.Visible = True
WordApp.Documents.Open FileName:=asFileName & ".rtf"
Set WordDoc = WordApp.ActiveDocument

'--make changes to the file if you want
'--this turns revisions on
With WordDoc
.TrackRevisions = True
.PrintRevisions = True
.ShowRevisions = True
End With

WordDoc.SaveAs FileName:=asFileName & ".doc", FileFormat:=0

WordApp.Quit
Set WordApp = Nothing
Set WordDoc = Nothing

Kill asFileName & ".rtf"

End Function

Hope this helps.

by sixfourtykilo

Great coding, but still nix. It accomplishes the same thing as clicking the buttons on the toolbar. Formatting stinks and text is jumbled. What whould be a 6 page report winds up being a 14 page report. Half of the pages come up blank with only footers, while the pages that do contain data is jumbled and unintelligible.

Thank you for your response!
640k

by sixfourtykilo

I'm wondering if this question requires a little more in-depth thinking than realized. I have increased the points as I do with all questions I find that perplex my fellow colleagues.

by mtnsqs

Could your formatting problems be anything to do with the default fonts - I have no idea what Access "assumes" is the default font for Word, but presumably it does its reprot using some known font - your word default fornt may be a different one - so if you can work out what Access is assuming, and change the font to that then maybe the report will look right

by sixfourtykilo

Wow you almost sparked some new acitivity in the thought process of how to resolve this issue. Word uses Times New Roman at size 10 as its default font, so I tried this. It looked cleaner but still became jumbled at the end. Then I noticed that wherever there were blank lines, the font was set to MS Sans Serif, a bitmap font. I tried this as well with disasterous results! Then I tried the MS Sans Serif font in size 12 like it was showing up and then converting to... anything size 10. Wellthings started fitting on the page, but it didn't fix the jumbling at the end. I'm beginning to think that this is going to require some intuitive coding to get it to work properly.

Thank you for your response!
640k

by mtnsqs

My previous answer clearly put you onto the path to solving the problem - so why did you reject it instead of giving me the points!

by sixfourtykilo

I think - "Well things started fitting on the page, but it didn't fix the jumbling at the end. I'm beginning to think that this is going to require some intuitive coding to get it to work properly. " - says it all. No matter how I adjust the font, some areas of text was appearing in other areas of text that has nothing to do with each other. In other words, fields were getting combined with other fields, even though they are seperated out in the report. I have learned from other sources thatthe only way to solve the problem correctly, and efficiently, is to code it. The above code doesn't offer me the correct solution either because it performs the equivilant as pressing the little button on the toolbar.

I also said, "Wow you almost sparked some new acitivity in the thought process of how to resolve this issue." So you haven't actually put me on the correct path to anything.

Thank you anyways.
640k

by sixfourtykilo

I've managed to combine coding and using a template in word to get the data to export properly. I'm not satisfied with the idea of having to tag along a document template anywhere and everywhere the database may go (too much overhead). I would like to code it completely in VB and eliminate the template, but I fear that I may be stuck! I'll leave the question open for another week or two.

Thank you everyone for your input!

This discussion is closed to new replies.