Roger's Access Library Homepage
Forum Home Forum Home > Roger's Access Library > Roger's Download Samples
  New Posts New Posts RSS Feed - AutomatingWordFromAccess.mdb (advanced)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

>
Want a good read? Try The Summer of His Life (available on Amazon!)

AutomatingWordFromAccess.mdb (advanced)

 Post Reply Post Reply
Author
Message Reverse Sort Order
Roger Carlson View Drop Down
Microsoft MVP
Microsoft MVP


Joined: 20 Feb 2008
Status: Offline
Points: 261
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roger Carlson Quote  Post ReplyReply Direct Link To This Post Topic: AutomatingWordFromAccess.mdb (advanced)
    Posted: 31 May 2016 at 7:28am
Update to Access 2010+ ACCDB
Consider donating $1 per sample downloaded, find out why here.<
Back to Top
Sponsored Links
>
Want a good read? Try The Summer of His Life (available on Amazon!)

Back to Top
Roger Carlson View Drop Down
Microsoft MVP
Microsoft MVP


Joined: 20 Feb 2008
Status: Offline
Points: 261
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roger Carlson Quote  Post ReplyReply Direct Link To This Post Posted: 04 Aug 2008 at 3:45am
Please consider donating $1 per sample downloaded, find out why here.

AutomatingWordFromAccess

The Microsoft Office Suite has a number of tools for communicating between its products, the most powerful of which is Office Automation through VBA (Visual Basic for Applications). By exposing the underlying object model for each of its applications, Microsoft made it possible to exercise programmatic control not only within a particular application, but between applications.

In my last article, Easy Excel Charting from Access, I showed how to create Excel chart from Access. The charting capabilities of Access using MS Graph are fairly primitive, so by sending the data to Excel, I can have a much richer set of charting tools. However, what I never covered is what to do with charts once they've been created.

It would be useful to paste these charts into an Access report, but that's not possible. However, it is possible to programmatically create a Word document, write data from your database to it, and then paste the appropriate chart into the document, making Word a very powerful and flexible reporting tool for Access.

Automation Program Overview

I create the Access subroutine (called ExcelWordAutomation), which automates the process of creating the Word documents. The overall process goes something like this:

  1. Open the Word template to create the document.
  2. Open the Excel spreadsheet that has pre-created charts for insertion.
  3. Open a recordset with data for reports.
  4. Insert data from the first record into the first report.
  5. Copy the appropriate chart in Excel and past into the Word document.
  6. Save the Word document with an appropriate name.
  7. Loop to step 4 and repeat until the recordset is finished.
  8. Close Excel, Word, and all object variables.
...

For more, download the sample.

Download
Access 2000 MDB (90 KB):
AutomatingWordFromAccess2k.zip

Access 2010+ ACCDB: AutomatingWordFromAccess2010.zip

Consider donating $1 per sample downloaded, find out why here.<
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.