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 OLE: Strategy to save docs to db - feedback please?

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





PostPosted: Thu Jan 22, 2004 2:10 am    Post subject: Word OLE: Strategy to save docs to db - feedback please? Reply with quote



This is the only strategy I have managed to come up with - maybe I'm on the
wrong track, or someone can suggest a better idea... Any feedback
appreciated!

(Assume "MyApp" opens OLE instance of Word = "WordApp")

ISSUES:
- no LoadFromStream functionality possible for handling multiple docs
- cannot reliably trap WordApp save-doc events
- even if you could trap save events, MyApp can only respond "silently" (no
user prompts - eg to save new docs) while WordApp is active app (would have
to wait until user returns to MyApp)

STRATEGY:
- stream db doc from MyApp to temp file, open in WordApp & activate (user
may return to MyApp and open another doc...)
- maintain list of docs accessed (MyApp owned, but hooked into WordApp
object since it must persist after WordApp possibly destroyed)
- access this list on return to MyApp (DURING or AFTER scope of WordApp) and
resolve changes...
* check if (existing) temp-file docs have been changed (date modified
changed) & update db if necessary (stream back from temp file).
* prompt to store any new docs created from WordApp

Responses to doc list history include:
- doc not modified, so no action
- doc modified, so update db
- doc is new (not sourced from db), so prompt to insert into db
- doc saved under another name, so prompt update or insert or ignore
- doc is still open in WordApp pending save, so action pending too

Thanks.

--
Brent Rose
[email]brentrose (AT) paradise (DOT) net.nz[/email]


Back to top
Oliver Townshend
Guest





PostPosted: Thu Jan 22, 2004 8:42 am    Post subject: Re: Word OLE: Strategy to save docs to db - feedback please? Reply with quote



Quote:
This is the only strategy I have managed to come up with - maybe I'm on
the
wrong track, or someone can suggest a better idea... Any feedback
appreciated!

- cannot reliably trap WordApp save-doc events

? Why not. I've never had any problems.

Quote:
- even if you could trap save events, MyApp can only respond "silently"
(no
user prompts - eg to save new docs) while WordApp is active app (would
have
to wait until user returns to MyApp)

Have you never written a Word Macro? If you write a FileSave macro, you can
have any code you want at time of save. This isn't too hard. Why don't you
write Word Macros or a Word OLE add in to do what you want? Check out
www.afalinasoft.com for a good OLE Add-in tool.

Oliver Townshend



Back to top
Brent Rose
Guest





PostPosted: Thu Jan 22, 2004 8:03 pm    Post subject: Re: Word OLE: Strategy to save docs to db - feedback please? Reply with quote



Thanks for the reply Oliver.

Quote:
Have you never written a Word Macro? If you write a FileSave macro, you
can
have any code you want at time of save. This isn't too hard. Why don't
you
write Word Macros or a Word OLE add in to do what you want? Check out
www.afalinasoft.com for a good OLE Add-in tool.


OK - I'm not aware of the full potential of VB macros in this context! I
understand that you can respond to these events within Word, but I haven't
made the connection as to how this helps me seamlessly integrate Word and my
Delphi app - eg stream a copy of the doc file back into a database (with
possibly some prompting along the way)...

I'll check out your suggested link...

Quote:
Oliver Townshend




--
Brent Rose
[email]brentrose (AT) paradise (DOT) net.nz[/email]



Back to top
Brent Rose
Guest





PostPosted: Fri Jan 23, 2004 4:48 am    Post subject: Re: Word OLE: Strategy to save docs to db - feedback please? Reply with quote

Quote:
- cannot reliably trap WordApp save-doc events

? Why not. I've never had any problems.

OK Oliver - could you be a little more specific please?

How are you managing to respond to save events in your Delphi app????

The "Word event sink" examples in D5/D7 only respond to limited Word
events - eg only Close/New/Open for doc object (I note VB help also says
that's all there is - so I guess the save events you speak of belong to some
other object??)....

Is it actually possible to expand the "sink" to trap these other events as
well??

At this stage of my very humble understanding, I cannot see how a Word macro
can notify MyApp of the after-save event.... do you mean that a macro can
generate an event that the "sink" can respond to?? How is this achieved??
Are you suggesting an "add-in" can do it as well?

Anyway ...an event in my Delphi app fired whenever Word has saved a doc
"belonging" to MyApp (and thereby enabling it to copy the doc to the db) is
exactly what I need....

Thanks Oliver - hope you or some one else can clear up my confusion!

--
Brent Rose
[email]brentrose (AT) paradise (DOT) net.nz[/email]




Back to top
Oliver Townshend
Guest





PostPosted: Sat Jan 24, 2004 5:20 am    Post subject: Re: Word OLE: Strategy to save docs to db - feedback please? Reply with quote

Quote:
At this stage of my very humble understanding, I cannot see how a Word
macro
can notify MyApp of the after-save event.... do you mean that a macro can
generate an event that the "sink" can respond to?? How is this achieved??
Are you suggesting an "add-in" can do it as well?

Hmm... I hadn't realized FileSave wasn't event sinked, as I've only ever
written the FileSave macro (it's always to control Word from within than
without). What you will have to do is write a FileSave macro which does
API/DLL calls to achive what you want.

Quote:
Anyway ...an event in my Delphi app fired whenever Word has saved a doc
"belonging" to MyApp (and thereby enabling it to copy the doc to the db)
is
exactly what I need....

Which means unfortunately that the FileSave macro will have to be in the
master template that your documents are based upon. Tricky but doable.

Oliver Townshend



Back to top
Brent Rose
Guest





PostPosted: Sun Jan 25, 2004 3:27 am    Post subject: Re: Word OLE: Strategy to save docs to db - feedback please? Reply with quote

Quote:
Hmm... I hadn't realized FileSave wasn't event sinked, as I've only ever
written the FileSave macro (it's always to control Word from within than
without). What you will have to do is write a FileSave macro which does
API/DLL calls to achive what you want.

Thanks Oliver.

At this stage, it would appear that the most practical option might be to
simply track the documents opened per MyApp and check if they have been
changed (or if they still have pending unsaved changes in Word) when MyApp
is re-focused. This, at least, seems easily achievable!

An API/DLL call to save the file to db from Word is not really feasible
given db security and access requirements etc - I think it would be just too
messy.

In any case, even if one could trap an after-save event in MyApp, things
could get a little messy handling any exceptions that might occur while
WordApp is focused...

--
Brent Rose
[email]brentrose (AT) paradise (DOT) net.nz[/email]



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.