vb123.com

Garry Robinson's Popular MS Access, Office and VB Resource Site

 

Home  Contact Us
Order our Software

RSS & Newsletter  
Join our XML/RSS Newsfeed or sign up for our informative newsletter on Office Automation, Access and VB topics
Read More

Get Good Help
If you need help with a database, our Professionals could be the answer
Read More

  Is Your Database Corrupt ?
If you have a corrupt database, Try our Access Recovery service

The Workbench  Find out who has your database open, start the correct version of Access, easy compacting and backups, change startup options, mde compile,  shutdown database Read and Download

The Toolshed 
Searchable help file comprising of all the information at vb123.com plus hidden downloads etc. Read More



The Toolbox

Libraries of software that we regularly import into our projects. Enhances the Toolshed More..


Upsize to SQL 
Upsize to SQL Server 2005 or 2008 or improve the performance of your Access to SQL Server application
Read More


DryToast New
Backup and query your BaseCamp
® projects
Read More


Datamining/Graphs

Explore your data with this versatile graphing and data mining shareware tool.  Read More

Garry's Blog
Find out a few other things that Garry has been writing about Microsoft Access. Read more

About The Editor 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
Contact Us ...

Search ...

or try our new Expression Web
 vb123.com.au
 

 

Next Tip  Automation Of Word Bookmarks - FXc8_Word

This page shows you how you might use demonstration code that you will receive with The Toolshed.

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 97 and 2000
Excel 97 and 2000

For all of them you need an additional reference to

Word 8 Object library or Word 9+ Object Library (if you use Office 2000+)

Download Files

  Click here for the download file if you own "The Toolshed"  Else ???   

Other Pages On This Site You Might Like To Read

Consolidate your data with queries
 

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

 

Links >>>  Home | Search | Workbench | Orders | Newsletter | Access Security | Access professionals