Export Access Queries to a Word Doc via a VB6 Program 
Author Message
 Export Access Queries to a Word Doc via a VB6 Program

As the title suggests I'm doing a little of everything here.  Anyway, here's
my situation.  My program is written in VB 6 using MS Access as the
database.  Not all of my users will have Access however.  I have many
queries written in Access and want to export those queries to a word doc via
automation.  In my code snippet below I know I could replace "qry1" on the
.Content.InsertAfter...line with a string variable or literal text.
However, I want to export the query (and actually many others) to the word
doc to automate the creation of report.

In Access I could do this using OutputTo, but again my users won't
necessarily have Access.

Any thoughts on revising the code below to perform such a function?

Thanks in advance,


Public Function CreateReport()
    Dim wrdApp As New Word.Application
    Dim wrdDoc As Word.Document
    Dim x As Integer
    Dim y As Integer
    Dim dbsMSWL As Database
    Dim qry1 As Recordset

        Set dbsMSWL = OpenDatabase(App.Path & "\mswl.mdb")
        Set qry1 = dbsMSWL.OpenRecordset("qryTeamStandings")

           wrdApp.Visible = True

        Set wrdDoc = wrdApp.Documents.Add

        With wrdDoc
                .Content.InsertAfter qry1
                .SaveAs ("C:\MyNewWordDoc.doc")
        End With

        Set wrdDoc = Nothing
        Set wrdApp = Nothing


End Function

Tue, 17 Jul 2001 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Exporting Access records to MS Word via VB6 front end app

2. Programmatically setting the Save As filename in a Word doc via VB6

3. Exporting a chart from and Access report to a word doc

4. Exporting Access Query SQL via WSH

5. automatically create word doc from access query

6. Exporting Access query to Word Document

7. ACCESS query to WORD document via Automation

8. Query an access database via SQL in VB6

9. Exporting Access records to MS Word vis VB6 front end app

10. Renaming an Access field (reserved word) via VB6

11. Insert an embedded word doc from access in word

12. Word objects from Acces via VB6 to WORD document


Powered by phpBB® Forum Software