Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Create Word Doc from Access Report, not rtf

Posted on 2008-06-13
5
Medium Priority
?
1,972 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 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

705 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