Solved

communicate with word and delphi 1.0

Posted on 1997-04-30
7
417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

705 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