Next Tip  Automation Of Word Bookmarks - FXc8_Word

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

What Do You Have To Do In Word ?

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.

What Do You Have To Do To Add The Software To Your Application

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.

What Actually Happens ?


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.

What Tools Can You Use

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+)

  Your Sample Database Is Called   "wordrep.zip"

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.

 

Other Pages On This Site You Might Like To Read

Consolidate your data with queries
Implementing a Successful Multi-user Access/JET Application
How To Create A Crosstab Query

Click on the following button Next Tip to jump to the next page in the document loop.

 

Our Tools and Resources

  • RSS & Newsletter Here
    Join our newsfeed or sign up for our informative newsletter on Office Automation, Access and VB topics
  • Get Good Help
    If you need help with a database, our Australian Professionals could be the answer

  • Smart Access is online 
    The best magazine written about Microsoft Access is now being transferred to the web. There are 400 articles written by a 100 authors in the collection. 

    Purchase Smart Access

  • The Workbench
    Find out who has your database open, start the correct version of Access, easy compacting and backups, change startup options, creation versions,  shutdown database

  • Convert Access to SQL Server  
    Upsize to SQL Server 2005 or 2008, easily repeated conversions, highly accurate SQL query  translation and web form conversion.
  • Purchase the Popular FMS Products  
    If you purchase the Popular FMS products from us, you will receive a complimentary of Smart Access Gold, Silver or Bronze Collections [Your choice]

 

 

vb123 Professionals


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

Access 2003 Security

MS Access Security

Read More here