{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} { Downloaded from The Coder's Knowledge Base } { http://www.netalive.org/ckb/ } {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} { @ CKB Header Version.: 1.01 } { @ Category ID........: delphi_misc } { @ Added to database..: 14.10.98 } {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} { @ Title..............: DDE connection to WinWord } { @ Original Filename..: DDEWiNWord.txt } { @ Author.............: Jean-Yves } { @ Description........: How to connect via DDE to WinWord } { @ Tested w. Compiler.: not tested yet } { @ Submitted by.......: Mike Orriss (mjo@3kcc.co.uk) } {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} Here is one very simple example of a DDE link with WinWord 6. It IS working. In Word you have to create a file (DDETEST.DOC in this example) and define a bookmark named "Bm1". {------------------- complete source code --------------------------} unit Unit1; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DdeMan; type TForm1 = class(TForm) DdeConv: TDdeClientConv; Word: TButton; procedure WordClick(Sender: TObject); private { Private-déclarations } public { Public-déclarations } end; {DdeConv properties are : } { ConnectMode : ddeManual } { DdeService : [None] } { DdeTopic : [None] } { FormatChars : False } { Name : DdeConv } var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.WordClick(Sender: TObject); begin if DdeConv.SetLink( 'WINWORD', 'D:\WINWORD\DDETEST' ) and DdeConv.OpenLink then begin ShowMessage( 'Link with WinWord established !' ) ; { be sure the link exist } DdeConv.PokeData( 'Bm1', 'Data from Delphi !' ) ; { insert 'Data from Delphi' in word document } DdeConv.CloseLink ; end ; end; end. {------------------- end of source code --------------------} Once you know that it is working it is easier to make it working ! Jean-Yves