?
Solved

communicate with word and delphi 1.0

Posted on 1997-04-30
7
Medium Priority
?
419 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

765 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