BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Word updates database on save....

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Bryan Thorell
Guest





PostPosted: Fri Apr 22, 2005 8:31 pm    Post subject: Word updates database on save.... Reply with quote



Hi, I'm hoping someone can give me a clue here...

I'm working on an application that automates Word to do a Mail Merge,
which comes up with a new document which the user can then modify
before printing.

At the point the document is closed, I would like to take that
document (merged/edited) and save it as a blob back into the database
(or write it out as a file)

I can grab the "Merged" document and save it to a file after it is
merged, but how can I make word save changes to my file when the
document is closed? I have noticed that in D7 there are the Word
servers which contain an OnClose for the Document, but the application
I am using is creating the Word application as a variant and I can't
seem to set the OnClose like: WordDoc.OnClose := procedure, it's
saying I don't have enough parameters???

Any help will be greatly appreciated.



Example Below:




var
WordApp, WordDoc : variant;
MergedDoc : variant;

WordApp := CreateOLEObject('Word.Application');
WordDoc := WordApp.Documents.Add(Template := aTemplateFN);

WordDoc.MailMerge.Execute;
Application.ProcessMessages;
MergedDoc := WordApp.ActiveDocument;

MergedDoc is the document that is created after the merge process,
this is what I want to make sure I save (with any changes).


Bryan Thorell
Back to top
George Birbilis
Guest





PostPosted: Sun Apr 24, 2005 10:55 am    Post subject: Re: Word updates database on save.... Reply with quote



a word server object of Delphi can connect to existing instance of Word, so
you can keep your code and also connect such an object to that word instance
to get back events (if you have many word instances running you'll have a
problem with this strategy though)

with the variant you have to use connection points etc. I think
http://www.gekko-software.nl/Delphi/art10.htm
might help


--
-----
George Birbilis (birbilis (AT) kagi (DOT) com)
Microsoft Most Valuable Professional
MVP J# for 2004 & 2005
http://www.kagi.com/birbilis
--------------

Quote:
Hi, I'm hoping someone can give me a clue here...

I'm working on an application that automates Word to do a Mail Merge,
which comes up with a new document which the user can then modify
before printing.

At the point the document is closed, I would like to take that
document (merged/edited) and save it as a blob back into the database
(or write it out as a file)

I can grab the "Merged" document and save it to a file after it is
merged, but how can I make word save changes to my file when the
document is closed? I have noticed that in D7 there are the Word
servers which contain an OnClose for the Document, but the application
I am using is creating the Word application as a variant and I can't
seem to set the OnClose like: WordDoc.OnClose := procedure, it's
saying I don't have enough parameters???

Any help will be greatly appreciated.



Example Below:




var
WordApp, WordDoc : variant;
MergedDoc : variant;

WordApp := CreateOLEObject('Word.Application');
WordDoc := WordApp.Documents.Add(Template := aTemplateFN);

WordDoc.MailMerge.Execute;
Application.ProcessMessages;
MergedDoc := WordApp.ActiveDocument;

MergedDoc is the document that is created after the merge process,
this is what I want to make sure I save (with any changes).


Bryan Thorell



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.