Hi John,

I write an addin for Outlook that uses Contact info and performs Mail
Merges using word, it uses the object model and uses a temp Word
Document as the data source so I'm not too sure if this helps you at
all, it does work quick though, all done in the background.

Regards

Jason Coley
Manawatu Software Solutions
email: [EMAIL PROTECTED]
web: http://www.software-solutions.co.nz



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On
Behalf Of John
Sent: Wednesday, 11 December 2002 6:23 p.m.
To: Multiple recipients of list delphi
Subject: [DUG]: MAIL MERGE with MS-Word

G'day folks,

I've asked this question a little while ago but did not get any reply.
There
must be people out there having developed a Mail Merge utility.
So if anybody could help me with this (either solving my question below,
or
having another approach) would be highly appreciated.


I'm using example code from
http://www.djpate.freeserve.co.uk/AutoWord.htm
providing an example on how to insert text into a Word document and how
to
create a mail-merge. The example uses a paradox example table
(customer.db).
This looks really great, however!!!

1.      It works only when I remove 'DSN=Paradox Files;' in the
connection
string.
        SEE:    ///Connection := Format('DSN=Paradox Files;


2.      The defined WHERE clause is ignored, is shows all records!
        SEE:    SQL := 'SELECT * FROM customer.db where Processed =
''n''';

Any ideas?

Thanks a lot for any help.

John

------------------------------------------------------------------

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  {$IFDEF VER130}
    Word97,
  {$ELSE}
    Word_TLB,
  {$ENDIF}
  StdCtrls, Db, DBTables, Dialogs;

type
  TMainForm = class(TForm)
    ...
  private
    Word: _Application;
    Doc : _Document;

...

procedure TMainForm.GetDataSourceBtnClick(Sender: TObject);
var
  TblName        : string;
  Connection, SQL: OleVariant;
begin
  { Open the customer table }
  TblName := AliasPath + '\' + 'customer.db';
  if fileExists(TblName) then
  begin
    ///Connection := Format('DSN=Paradox Files;

    Connection :=
Format('DBQ=%s;DefaultDir=%s;DriverId=538;MaxBufferSize=2048;PageTimeout
=5;'
, [AliasPath, AliasPath]);
    SQL := 'SELECT * FROM customer.db where Processed = ''n''';
    Doc.MailMerge.OpenDataSource(TblName, EmptyParam, EmptyParam,
EmptyParam,
                                 EmptyParam, EmptyParam, EmptyParam,
EmptyParam,
                                 EmptyParam, EmptyParam, EmptyParam,
Connection,
                                 SQL, EmptyParam);

------------------------------------------------------------------------
---
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to