Solved

communicate with word and delphi 1.0

Posted on 1997-04-30
7
413 Views
Last Modified: 2010-08-05
I need to control MS Word from delphi 1.0 program. Is there any way to use word macro functions from delphi 1.0? I have send macro commands via dde, but no luck with functions so far.

...you guys are very precise!

I'm trying to do mailmerge from my delphi program. I need to know what documents are open in word and is the current document already mailmerged (data inserted). My program needs to open some documents (user defines the name), perhaps by using word:s own fileopen dialog. And in the end close word if it was not already open when starting mailmerge.

If you wanna know more details...please mail me
"janne.timmerbacka@mechaul.com"
0
Comment
Question by:olmy
7 Comments
 

Expert Comment

by:lkovac
ID: 1335789
You have to display this more clearly, do you need to control MS Word from Delphi 1.0 application, or you need some WinBatching 16 bit system, or what ?
0
 
LVL 1

Author Comment

by:olmy
ID: 1335790
Edited text of question
0
 
LVL 2

Expert Comment

by:gysbert1
ID: 1335791
Please explain what you want to do ...

What do you want to control, which functions do you want to call and why ?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Author Comment

by:olmy
ID: 1335792
Edited text of question
0
 
LVL 3

Expert Comment

by:hpierson
ID: 1335793
I have done this sort of thing with Delphi 1.0 and Word 2.0 and word 6.0.

What version of word do you need to work with? Unfortunately, MS in their wisdom keeps breaking code...

P.S Personally, I think this is worth more than 50 pts...it took me a while...
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 250 total points
ID: 1335794
to operate word commands from delphi1 you use DDE.
Advantages:
1. using ole in delphi1 is very complicated.
In Delphi2 you can use Ole Automation which is simple to use.
2. DDE works much faster then OLE.
Disadvantages:
1. DDE is less stable and requires more checking.
2. before using DDE you must run the word application.
In OLE Automation you don't have to run word application (but usually you will).

sample for opening a new document and inserting 2 lines in it:

uses ddeman;

procedure TForm1.Button1Click(Sender: TObject);
var
  DdeClientConv1: TDdeClientConv;
  DdeClientItem1: TDdeClientItem;
  Buf: PChar;
begin
  DdeClientConv1:=TDdeClientConv.Create(Form1);
  DdeClientItem1:=TDdeClientItem.Create(Form1);
  DDEClientItem1.DDEConv := DDEClientConv1;
  GetMem(Buf,100);
  Buf[0]:=#0;
  with DdeClientConv1 do
  begin
    ConnectMode := ddeManual;
    SetLink('WinWord','System');
    OpenLink;
    StrCat(Buf,'[FileNewDefault][Insert "Example for dde"][InsertPara][Insert "from Delphi"]');
    ExecuteMacro(Buf,False);
    CloseLink;
  end;
  FreeMem(Buf,100);
  DDEClientItem1.Free;
  DdeClientConv1.Free;
end;

Remarks:
1. if you want your delphi code wait until all processing in word was done,
at the end you write the command:
while WaitStat do
  Application.ProcessMessages;
2.The character " has a special meaning in word, therefore, if you want to insert
a string which contains this character you use Chr$(34) instead. for example,
if you want to insert the string 13" (13 intches) you write the following code:
    StrCat(Buf,'[Insert "13 + Chr$(34) + "]');

0
 
LVL 1

Author Comment

by:olmy
ID: 1335795
Sorry Ronit! You have great answer but it is not what I'm looking for.

FUNCTIONS!!!! Here is a simple example: "CountWindows"-function in word (what version, not important ~7.0). How do I get the function return value (countwindows) to my program, when I'm using DDE (delphi 1.0)?



0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now