Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create Word Doc from Access Report, not rtf

Posted on 2008-06-13
5
Medium Priority
?
1,979 Views
Last Modified: 2013-11-28
I wish to export a report to a Word doc. I know the formatting won't export, thats fine.
Here's my code:
  stCriteria = "Tran_ID = " & lTranID
   stReport = "rptFleet_Deletion"
   stPath = "c:\Fleet_Deletion.Doc"
   DoCmd.OpenReport stReport, acViewPreview, , stCriteria, acHidden
   DoCmd.OutputTo acOutputReport, stReport, acFormatRTF, stPath, True
   DoCmd.Close acReport, stReport

I'm cheating to an extent, in that I'm actually creating an rtf file, but calling it .Doc
Seems to work ok on my PC, but I'd like to be sure before I distribute.
Will this cause problems on any PCs? That is, I don't want users to get a warning about the format being rtf or somesuch.
Thanks

0
Comment
Question by:jdhackett
  • 3
  • 2
5 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 21777648
Word cann open an .rtf or a .doc file. There is no need to give it the wrong extension. Once open it can be saved back in either format.
0
 
LVL 1

Author Comment

by:jdhackett
ID: 21777671
I don't want to confuse users and ask them to save it as a .doc
If I give it the wrong extension, will it actually cause any issues?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 21777733
Files are internally identified as well, so applications that can read either format will not have any trouble. Explorer will open the application that the extension points to, so double-clicking on the file name in explorer will call on Word to open it.

If the user does a Save As, Word will save it as RTF  by default and suggest an rtf extension.  You may consider this an issue.
0
 
LVL 1

Author Comment

by:jdhackett
ID: 21778354
Hmm, so it does. Thanks for spotting that.
Is there a way around this?
Or a different command that does let me create an actual Word Doc?
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 21780460
I think rtf was chosen as being the more open format. If you have Word, you could add code to open the file in Word and save it again in Document format. The snippet uses early binding, so needs a reference (Tools/References in VBA editor) to the Microsoft Word Object Library
    Dim wdAPP As Word.Application
    Dim wdDoc As Word.Document
    
    Set wdAPP = New Word.Application
    wdAPP.Visible = True 'optional
    Set wdDoc = wdAPP.Documents.Open("C:\MyFolder\MyFile.rtf")
    wdDoc.SaveAs "C:\MyFolder\MyFile.doc", wdFormatDocument
    wdDoc.Close wdDoNotSaveChanges
    wdAPP.Quit
    Kill "C:\MyFolder\MyFile.rtf"

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question