Solved

Create Word Doc from Access Report, not rtf

Posted on 2008-06-13
5
1,964 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Independent Software Vendors: 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

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

735 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