Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Access Data to Word document (automation?)

davepacebrightdavepacebright Member Posts: 1
Hello all,

I'm new here and was hoping for some help.
The department that I work in sell Insurance and currently have to manually fill in the blanks in a Word document to complete a perticular type of policy sale.

I have created an Access database that is used for various tasks. I have created a table to hold the data of above sales but wondered if there was a way to automate the transfer of this data from my database to the Word document already in use (rather than doing it manually)

It would also be helpful if this automatically saved in a specific location after the data transfer.

The only solution I can think of, other than the suggestion above is to build a report that is identical to the current Word doc??

Any suggestions please

Many thanks
Dave Pace

Comments

  • dokken2dokken2 Member Posts: 532
    yes, its possible. the trick is in word to create a mailmerge document-

    (briefly, on word 2002 mail merge toolbar-)
    open data source
    provider tab/new source
    other/advanced
    jet 4.0 ole
    connection tab/... browse to access.mdb

    insert merge fields- choose the fields


    'requires reference set to
    'MICROSOFT WORD xx.x OBJECT LIBRARY
    '
    Sub Merge()
    Dim WordApp As New Word.Application
    Dim MyDoc1 As String
    Dim MySave As String
    Dim MyMDB As String

    'word doc filename
    MyDoc1 = Application.CurrentProject.Path & "doc1.doc"
    'word save filename
    MySave = Application.CurrentProject.Path & "doc2.doc"
    'access filename
    MyMDB = Application.CurrentProject.Path & "access.mdb"

    'show word
    WordApp.Visible = True
    'open mailmerge word doc
    WordApp.Documents.Open (MyDoc1)

    'perform mailmerge
    With WordApp.ActiveDocument.MailMerge
    .MainDocumentType = wdFormLetters
    .OpenDataSource MyMDB, False, False, True, False, False, , , , , , "Table Table1", , "", False
    .Destination = wdSendToNewDocument
    .SuppressBlankLines = True
    With .DataSource
    .FirstRecord = wdDefaultFirstRecord
    .LastRecord = wdDefaultLastRecord
    End With
    .Execute
    End With

    'save/close files
    WordApp.Documents(1).SaveAs MySave
    WordApp.Documents(2).Close False
    'quit
    WordApp.Quit
    Set WordApp = Nothing
    End Sub
  • aks_bond28aks_bond28 Member Posts: 4
    HI friends.

    I am a college student and am currently undertaking a project wherein I need to link a C/C++ program to a database. I dont know SQL, and so will have to create the database using MS EXCEL or MS ACCESS.

    Can anyone please tell me how i can link my C program to an MS EXCEL or an MS ACCESS database.

    Thanks a lot.

  • dokken2dokken2 Member Posts: 532
    : HI friends.
    :
    : I am a college student and am currently undertaking a project
    : wherein I need to link a C/C++ program to a database. I dont know
    : SQL, and so will have to create the database using MS EXCEL or MS
    : ACCESS.
    :
    : Can anyone please tell me how i can link my C program to an MS EXCEL
    : or an MS ACCESS database.
    :
    : Thanks a lot.
    :
    :
    I'm not too familiar with C. in vb you can use the ADODC and datagrid controls, C likely has similar controls. you may consider posting your question in the c/c++ area
  • aks_bond28aks_bond28 Member Posts: 4
    thanks for replying..
Sign In or Register to comment.