Board index » delphi » Getting data from Delphi app into Word document

Getting data from Delphi app into Word document

Hi,

I got a Delphi app. I need to get fields from my database (DBase IV)
into a Word document to produce customer specific letters.

Can someone tell me how to do this please?

I've looked in Delphi and Word documentation.

Cheers
Lee

 

Re:Getting data from Delphi app into Word document


Lee Davis  wrote in article ...

Quote
> I got a Delphi app. I need to get fields from my database (DBase IV)
> into a Word document to produce customer specific letters.

Assuming that you have Word2(6)/Delphi1 or 32bit Word/Delphi2.
Try:

1. Make macro in Word:
-------------snip--------
Declare Function StringFromDelphi  Lib "c:\sample\test.dll" As String

Sub MAIN
mystring$ = StringFromDelphi
Insert mystring$
End Sub
-------------snip--------

2. Create simple TEST.DLL in Delphi - just form with a button.
   Save it (eg.in c:\sample - see Word macro) as test.dpr
   and testform.pas. Now add to your project EXPORTED function
   'StringFromDelphi' and 'close' on button click.
   You can paste the stuff from below:

-------------snip--------
library Test;  (* test.dpr in c:\sample *)
uses Testform in 'TESTFORM.PAS';
exports
    StringFromDelphi;
begin
end.

-------------snip--------
unit Testform; (* testform.pas in c:\sample *)
interface
uses
WinTypes, WinProcs, Forms, Classes, Controls, StdCtrls, SysUtils;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;
var
  Form1: TForm1;

function StringFromDelphi : PChar; export;
                     {$ifdef WIN32} stdcall; {$endif}

implementation
{$R *.DFM}

function StringFromDelphi: Pchar;
var StringForWord : array[0..255] of char;
begin
    Application.CreateForm(TForm1, Form1);
    Form1.ShowModal;
    Result:=StrPCopy(StringForWord, Form1.Button1.caption);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    close;
end;

end.
-------------snip--------

3. Compile test.dll. Run macro from Word, Delphi form should
   appear - click the button to get some data from Delphi.

There is a text in PCMagazine Vol12.No22 on accessing DLL functions
from Word. You can get it (DLLACCES) from PCMag web site.

Regards, Darek Maluchnik

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

Re:Getting data from Delphi app into Word document


Look into OLE automation.

Re:Getting data from Delphi app into Word document


Hi,

If You use D1 then try with DDE.
If You use D2 then try with OLE.

Also, look in Word help for Mail Merge.

Bye.

Lee Davis <leeda...@feelthe.force9.net> wrote in article
<332d6f8d.20714...@news.force9.net>...

Quote
> Hi,

> I got a Delphi app. I need to get fields from my database (DBase IV)
> into a Word document to produce customer specific letters.

> Can someone tell me how to do this please?

> I've looked in Delphi and Word documentation.

> Cheers
> Lee

Re:Getting data from Delphi app into Word document


Quote
Kees de Kooter wrote:

  Look into OLE automation.

 Which brings up my question.  Does Delphi 1 (16 bit) do
OLE?automation?

Other Threads