Results 1 to 2 of 2

Thread: Query Export

  1. #1
    Join Date
    Oct 2003
    Posts
    58

    Unanswered: Query Export

    Hi all,

    I have this bit of code to export a query to word..... how can i enter text into the document?


    Private Sub Command3_Click()

    Dim Word As Object
    Dim strQRY As String
    Dim dbs As Database
    Dim qry_RCS As Recordset
    Dim rtn As String
    Dim numB As Integer

    numB = 1

    Set dbs = CurrentDb

    'Set Query
    strQRY = "SELECT * FROM some_table"

    'Set Recordset
    Set qry_RCS = dbs.OpenRecordset(strQRY, dbOpenDynaset, dbSeeChanges)

    Do Until qry_RCS.EOF

    'Create Excel as an Object
    Set Word = CreateObject("Word.Application")

    Word.Application.Visible = False
    Word.Application.Documents.Add

    word.<enter text here but i dont know the function names>

    Word.Documents.Add "E:\ID.doc"

    Word.Application.Documents.Close
    Word.Application.Visible = False

    qry_RCS.MoveNext

    Loop
    Exit Sub

    End Sub

    Thankyou...

    Jnr.

  2. #2
    Join Date
    Feb 2004
    Location
    Dorset UK
    Posts
    147
    I wrote a bit a while ago for Word (didn't like it much) but it went like this:


    Set Word = CreateObject("Word.application")

    Word.Application.Visible = True
    Word.Application.Documents.Add

    Word.Documents.Add

    Word.Selection.TypeText Nz("Your Text here", " ")
    Word.Selection.TypeParagraph
    Word.Selection.TypeText Nz("and here", " ")


    You can canabalise this to your hearts content !!

    Hope it gets you going in the right direction.

    Ken.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •