vb123.com.au
This page shows you how you might use demonstration code that you will receive with The Toolbox.
The Word class module is a simple to use class module that is
designed to get you started in the right way in your quest to automate Microsoft
Word. This class module comes with all the source code so that you can take your
software where you need to go.
Here is an example of the code that would run open an existing Word report using
Visual Basic 6, add some text and print it out. The bolded text shows the class
module in action.
Dim fileName As String, wordExport As FXc8_Word, successInt As Long Set wordExport = New FXc8_Word With wordExport fileName = "c:\fxClasses\wordRep.doc" successInt = .openWord(fileName) If successInt = True Then .gotoBookmark "Address1" .addText "555 Willow Drive" .gotoBookmark "Address2" .addText "Sydney" .gotoBookmark "State" .addText "NSW" .gotoBookmark "Postcode" .addText "2000" .gotoBookmark "Name" .addText "John Smith" .printDoc .closeDoc .Finished Else ' Opening the file has failed .Finished End If End With
Take any word document and place it in a directory where all users of your
software can reference it
Clean out any text that you are going to replace with your software
Add bookmarks to the word document where you are going to insert the text from
your software.
Take a backup of the file to use as a template.
Experiment with the sample application that you want to launch your Word report
from. Working projects are provided for Access, Excel and Visual Basic.
Bring your word report into the test environment and add the bookmarks that you
need.
Add the text that you want to add to the document
Now add the formfields or data extraction software so that you can display your
data on your word report.
Move the sample application into your existing application.
In the Excel Example, you would have a worksheet that looks like example 1

Example 1 - A Worksheet that runs a Word Report using the data typed into the
cells
When you click on the Print Report Command button, it runs the visual basic code
and the class module to produce a word report that looks like example 2.

Example 2 - A Word document produced by the FX class module for Word
Reports.
In the word report, the bookmarks are place markers that decide where the
information is to be placed. The bookmarks do not appear on the document when it
is printed.
Microsoft Access 2000 and beyone
Excel 2000 and beyond
For all of them you need an additional reference to
Word 8 Object library or Word 9+ Object Library (if you use Office 2000+)
Sample database is suited to all versions of Access
If you do NOT own "The Toolbox", Click
here to find out how to purchase The Toolbox.
Consolidate your data with
queries
Implementing a Successful Multi-user
Access/JET Application
How To Create A Crosstab Query
Click on the following button
to jump to the next page in the document loop.
Get Good Help Here
If you need help with a database or
Office programming,
our Professionals could be the answer because we have worked on many
similar solutions
Frontpage Conversions
We have converted vb123.com to Expression Web,
contact us if we can help you move to the latest Microsoft web tool.
About The Editor ~ Contact Us
Garry Robinson writes for a number
of popular computer magazines, is now a book author and has worked on
100+ Access databases. He is based in Sydney, Australia