{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} { 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 WordPerfect } { @ Original Filename..: DDEWordperfect.txt } { @ Author.............: John Studt } { @ Description........: How to connect via DDE to WordPerfect } { @ Tested w. Compiler.: not tested yet } { @ Submitted by.......: Mike Orriss (mjo@3kcc.co.uk) } {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} Here is a sample procedure that I use that works: procedure TForm1.PrintSave(Doc : String); var ProdDoc, ArchDoc : String; WPCommands : TStringList; begin ProdDoc := ProdDrive + Doc; ArchDoc := ArchDrive + Doc; WPCommands := TStringList.Create; with WPCommands do begin Add('FileOpen(Filename:"'+ProdDoc+'")' ); Add('FileSave(Filename:"'+ProdDoc+'";ExportType:3;Overwrite:1)'); Add('PrintCopies(NumberOfCopies:2)'); Add('PrintCopiesBy(CopiesBy:1) '); Add('PrintFullDoc() '); Add('DocCompare(FileName:"'+ArchDoc+'";CompFlags:1) '); Add('FileSave(Filename:"'+EMailDoc+'";ExportType:3;Overwrite:1'); Add('Close(Save:0) '); end; if PDDE.ExecuteMacroLines(WPCommands, True) then begin log('WPCommand Worked!') { I need to wait for WP to complete the command now... } end else log('WPCommand Failed!'); WPCommands.Free; end; A Coupla'notes: You cannot use the 'True!' or 'False!' equates as you would in a real WP Macro. You must use the numeric values. I have found that if you go into WP and use the macro build facility, you can extract the enumerated types by watching the dialogue box as you select the commands and their associated parameters. From what I can TELL, the way DDE works with WP/Delphi, the first command returns the 'Okay, I got it' message, and proceeds to process the macro. When you attempt to send the SECOND DDE request, IT waits for the first to complete, so where you see the 'I need to wait....' message, you get control back immediately. I would rather wait for the command to complete before I return from my procedure. John Studt