Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

communicate with word and delphi 1.0

Posted on 1997-04-30
7
Medium Priority
?
420 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 750 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

618 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