Link to home
Start Free TrialLog in
Avatar of pmle
pmle

asked on

Export Access Report into Word (without losing the formatting!)

I am trying to export an Access reoport (100+ pages).  I keep losing my formatting, and Word just decides to do all kinds of crazy things with my data, such as different spacing in different areas, and duplicating data.  The only reason that I even want to export to Word is to create a Table of Contents, and an index.  Is there any way to either fix the formatting issue in Word, or create a TOC and index on an Access report?  Thanks a bunch!!
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of puppydogbuddy
puppydogbuddy

Jim
Could you post the code for opening up a snapshot as an object in word. I've tried the following code that outputs a report selected from a listbox as a snapshot object, inserts it to a word document and attaches the document to an outlook email...and snpshot won't format at all.  The only thing that has come reasonably close to preserving the format has been when I export in rtf format.  My code using snapshot is excerpted below:

             'output value of bound column for selected list item to word
             DoCmd.OutputTo acOutputReport, ctlListBox.Column(0, varItem), acFormatSNP, "c:\Temp\" & ctlListBox.ItemData(varItem) & ".snp", False
             AppWord.Selection.InsertFile "c:\Temp\" & ctlListBox.ItemData(varItem) & ".snp", "", False, False, False
             If i < ctlListBox.ItemsSelected.Count Then
               AppWord.Selection.InsertBreak wdSectionBreakNextPage
             End If
         Next varItem
     
         'create email attachment
         Progress = "Generating Email"
         EventTitle = ctlListBox.ItemData(varItem)
         AppWord.ActiveDocument.SaveAs "c:\Temp\" & EventTitle & ".rtf", wdFormatDocument
         AppWord.ActiveDocument.BuiltInDocumentProperties("Title").Value = "Attached Word File - " & Date
         AppWord.ActiveDocument.Save