Solved

communicate with word and delphi 1.0

Posted on 1997-04-30
7
416 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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