VDF-GUIdance logo



  Visual DataFlex Logo
  

Shared knowledge leads to accumulated knowledge

        Printer Friendly Page


Size: 95 KB Download
Date Created: 06/10/1999
Date Updated: 03/06/2002
Author: Dan Walsh
Company: Legal Software Development
Summary:
This package shows you how to implement mailmerging in Microsoft's Word 97 with the use of FlexOLE. It is an example that makes use of the standard order entry sample which makes it much easier to understand. Another view is added, written by Peter Tawse, to automatically merge and print documents with Word in the background.

Mailmerging in Microsoft Word with FlexOLE/FlexCOM

How it works.
First of all, you must have FlexOLE and Microsoft Office 97 installed on your system.

Copy the .Doc Word document files to the Order entry example folder vdf6\examples\order\Data.
Copy the remaining files to the AppSrc directory.
Start the IDE in the order entry workspace
Select 'Register external component' from the 'Components'-menu and select the custmm1.vw file to register. Repeat this for the custmm2.vw file.
Include the Word8 and FlexOLE packages in your main program.
Object ProgramWorkspace is a Workspace
  Set WorkspaceName to CURRENT$WORKSPACE
  Set ModuleName to 'Order'
  Set HelpName to 'OrdEntry.hlp'
End_Object

Use Help_Ids.inc // Developer should provide this file of help context links.
Use Std_Help.pkg
// In VDF6, you should include:
//Use FlexOLE.pkg
// In VDF7 or higher, this is changed to:
Use FlexCOM.pkg
Use Word8.pkg

Add the new views to your program
Compile the Order Entry sample application.

Below is an example of how-to include those packages into VDF8
Object oApplication is a cApplication
    Set psCompany to "Data Access Worldwide"
    Set psProduct to "Visual DataFlex 8 Examples"
    Set psVersion to "8.0"
    Set psProgram to "Order"

    Set psHelpFile To "OrdEntry.hlp"

    Procedure OnCreate
        Send DoOpenWorkspace CURRENT$WORKSPACE
    End_Procedure

End_Object // oApplication


Use Help_Ids.inc // Developer should provide this file of help context links.
Use Std_Help.pkg
Use FlexCOM.pkg
Use Word8.pkg

Mailmerge example 1


  1. Open a new Word document.
  2. Select 'Mail Merge' from the 'Tools' pull-down menu.
  3. Select 'Form Letter' from the 'Create' pull-down and select the 'Active Window' as the Main document.
  4. Select 'Open Data Source' from the 'Get Data' pull-down menu. Open file 'CustMnDs.doc' in the Data directory.
  5. Create your letter inserting data fields as needed. (See the two example main documents provided.

Dan Walsh

Mailmerge example 2


My heartfelt thanks to Dan Walsh, who pioneered the creating of this prototype late in 1998 when most of us had'nt even thought about it !
Dan's "Custmm1.vw" code has been enhanced so that:
.
  1. It now automatically prints 2 letters - I needed to test this capability, and did so in rather a lazy manner, but it works and so I will now be writing a front-end capable of selecting database records that meet some pre-determined qualifying specifications.
  2. Word8 / Ms Word97 now automatically CLOSES when the job has been sent to the printer.
This was one of the requirements I needed to achieve - no use leaving an active App's window on-screen when it had done what I needed it to do.

Thanks to Dave Robinson for pointing me in the right direction on this one.

  1. All amendments carry "D Walsh" or "P Tawse" so if you are lookig for the alterations, search for either of these Tags.
My thanks also to those others who contributed assistance when I needed it most - much appreciated.

The VDF-GUIdance philosophy certainly makes life MUCH easier and more enjoyable

Peter Tawse
Microbase Software
MELBOURNE, AUSTRALIA

email: ptawse@tbsa.com.au
 

Notes
Be sure that you use the supplied version of the Word8.pkg file as this contains some fixes to known problems. The changed list of methods is:


  • Function DocumentsOpen
  • Procedure MailMergeOpenDataSource
  • In the OLEApplication Class the line: Import_Class_Protocol OLEApplicationEvents is commented out.
  • Procedure DocumentSaveAs
  • In the OLEDocument Class the line: Import_Class_Protocol OLEDocumentEvents is commented out.
  • Microsoft Office 2000 hasn't been tested with this package, but it should work as well as one of the premisses of a good OLE/OCX object is that it should always be upward compatible

Downloads



Ms Word Mailmerge example VDF6 version

mswordmmvd6.zip

Ms Word Mailmerge example VDF7/VDF8 version

mswordmmvd7.zip

Links



Order Expanded Example
DataPower from Torben Lund go to the download page (not available anymore)

Mailmerge code by Focus