Solved

Create Word Doc from Access Report, not rtf

Posted on 2008-06-13
5
1,965 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

752 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