[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1124
  • Last Modified:

Using DDEClientConv

I use a DDEClientConv to transfer data to a bookmarked Word document by using

DdeClientConv1.PokeData('Name', PChar(Edit1.Text));

It works OK, when I run the program from the Delphi platform, but running the program from outside the Delphi platform it doesn't work.

The MS-Word opens with the correct doc-file but, no data are transferred, using the PokeData procedure.
Can anybody tell me why?

Joern
0
rainbowsoftware
Asked:
rainbowsoftware
  • 5
  • 3
1 Solution
 
intheCommented:
might be better to post some more code ..

i can give example of using ole to insert text at a bookmark in word if that helps ..
0
 
rainbowsoftwareAuthor Commented:
I create and open the link by:

if DdeClientConv1.SetLink( 'WINWORD', 'Letter.doc' ) then DdeClientConv1.OpenLink;

And I transfer the data to the bookkmark by:

DdeClientConv1.PokeData( 'Name', PChar(Edit1.Text));

I have tried to write the whole path to Winword.exe:
 C:\Program Files\Microsoft office\Office\Winword

and the whole path to the doc:

C:\Documents\Letter.doc

but still it doesn't work, outside the Delphi platform.

Have you got another way to do it?

Joern

0
 
intheCommented:
only using ole ,dde always fails..
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
mhervaisCommented:
he is right rainbow. DDE is not worth trying.
0
 
intheCommented:
hi,
dde is dead ;-)

add oleauto to your uses section ,(can do similar with comobj) then

procedure TForm1.Button1Click(Sender: TObject);
var
WordApp : variant;
begin
  try
    WordApp := GetActiveOleObject('Word.Application');
  except on exception do
    WordApp := CreateOleObject('Word.Application');
  end;
 WordApp.wordbasic.fileopen('c:\test.doc');
 WordApp.Visible := True;
 WordApp.Wordbasic.EditBookmark('aBookmark', , , , -1);
 WordApp.Wordbasic.insert(edit1.text);
 WordApp.Wordbasic.insert(#13);
end;

that will got to your bookmark (named abookmark) and add some text from a tedit..

see these links to learn all about ole automation etc type of stuff:

there are tutorial (with code) about automating excel here:

http://hometown.aol.com/charliecal/TechPapers/DelphiWord.htm 

also a tutorial from borland:(see examples.zip for code)
http://www.inprise.nl/delphi/papers/microexcel/me3.html 

and another demo project here for putting data into excel:
http://inthe.future.easyspace.com/delphi/files/exceldde.zip 

also see some components here:

http://dsp.href.com/iis/iis.dll?DSP:RESULTS:723403184 

Regards Barry
0
 
intheCommented:
note,
to learn all the commands you can use you really need the vba help file ,this comes with most versions of office or it can be downloaded from various web sites just search for vba.hlp or something ..
0
 
rainbowsoftwareAuthor Commented:
Thanks very much to Barry for the code, and the links.
I can't use AutoOle, but ComObj is OK. Is it because I use Delphi 3?

Joern
0
 
intheCommented:
in delphi3 you should have some ole files in your delphi lib directory under the directory called delphi2..

it dont matter comobj be better anyway ..happy learning ;-)
0
 
rainbowsoftwareAuthor Commented:
Thanks again, it works perfect.
Joern
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now