Advertisement

05.23.2008 at 11:33AM PDT, ID: 23428538
[x]
Attachment Details

Export Query to MS Word table

Asked by bartjoosen in Microsoft Access Database, Access Reports, Access Coding/Macros

Tags: Microsoft, Access, Word

Hi,

I have an MS Access db which contains 2 queries.

What I want to do is to automatic generate a word document, which contains:
"A TITLE"
"results of query1:"
query1 (formated as a table)

"result of query2:"
query2 (formated as a table)


I searched on EE, and I came up with:
http://www.experts-exchange.com/Database/Miscellaneous/Q_20752299.html?sfQueryTermInfo=1+acc+tabl+word
But unfortunately I couldn't figure it out how to do it (links seems to be broken)

This is what I've got so far, after clicking a command button:

Private Sub btn_Click()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
    Set wrdApp = CreateObject("Word.Application")
    wrdApp.Visible = True
    Set wrdDoc = wrdApp.Documents.Add
   
    With wrdDoc
            .Content.InsertAfter "A TITLE"
            .Content.InsertParagraphAfter
            .Content.InsertAfter "results of query1:"          
            .Content.InsertParagraphAfter
' here should be the code to insert the results of query1 as a table
            .Content.InsertAfter "results of query2:"          
            .Content.InsertParagraphAfter
' here should be the code to insert the results of query2 as a table

End With

    Set wrdDoc = Nothing
    Set wrdApp = Nothing
End Sub


Thanks for your time

Bart
Start Free Trial
[+][-]05.24.2008 at 02:14PM PDT, ID: 21640264

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Access Database, Access Reports, Access Coding/Macros
Tags: Microsoft, Access, Word
Sign Up Now!
Solution Provided By: oldmanbim
Participating Experts: 2
Solution Grade: B
 
 
[+][-]05.24.2008 at 04:42PM PDT, ID: 21640617

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 05:12AM PDT, ID: 21642228

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 11:28AM PDT, ID: 21643341

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628