AfterSave Event ?

A

Andrew Kennard

Hi all

Word 2003 seems to have very few events to react upon ?

There is a BeforeSave but no "AfterSave"

I would likr to be able to copy the document to a folder when I 'flip back'
to my application (if it has changed)

Has anyone done anything similar ?

Thanks

Andrew
 
J

Jean-Guy Marcil

Andrew Kennard was telling us:
Andrew Kennard nous racontait que :
Hi all

Word 2003 seems to have very few events to react upon ?

There is a BeforeSave but no "AfterSave"

I would likr to be able to copy the document to a folder when I 'flip
back' to my application (if it has changed)

Has anyone done anything similar ?

Thanks

Andrew

Intercept the Save and Save As commands with macros named like this:

'_______________________________________
Sub FileSave()

End Sub
'_______________________________________

'_______________________________________
Sub FileSaveAs()

End Sub
'_______________________________________

Use code to do the save, and then do what you want to do. No need of events,
and if you want this to be global event try with a template located in the
Start-up folder
Normally, I use a third sub that actually does the work:

'_______________________________________
Sub FileSave()

SaveEvent 1

End Sub
'_______________________________________

'_______________________________________
Sub FileSaveAs()

SaveEvent 2

End Sub
'_______________________________________
'_______________________________________
Sub SaveEvent(lngSaveType As Long)

If lngSaveType = 1 Then
ActiveDocument.Save
Else
Dialogs(wdDialogFileSaveAs).Show
'In fact, you need more code here in case the user cancels out of that
dialog,
' you have to code accordingly
'See the VBA help file on Dialogs. Or do a Search in Google Groups,
'there are may example on how to do this
'If the document was not successfully saved with Save As:
Exit Sub
End if

'Do the stuff you want to do after the save here

End Sub
'_______________________________________



--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

Andrew Kennard

Jean-Guy

Thanks very much for your detailed reply.

Sorry I should have mentioned that I am 'integrating' with Word as a COM
automation object from a language called Visual Dataflex.

Now VB examples are usually fine and I can "convert" them

Would I be correct in assuming your example below is in VBA and is in effect
controlling word from the inside out rather than the outside in ?

Do you know how I could achive the same thing from a separtate VB app that
controls word as a COM Automation object ?

Thanks again for your assistance

Regards

Andrew
 
J

Jean-Guy Marcil

Andrew Kennard was telling us:
Andrew Kennard nous racontait que :
Jean-Guy

Thanks very much for your detailed reply.

Sorry I should have mentioned that I am 'integrating' with Word as a
COM automation object from a language called Visual Dataflex.

Ha, now you tell us!
Now VB examples are usually fine and I can "convert" them

Would I be correct in assuming your example below is in VBA and is in
effect controlling word from the inside out rather than the outside
in ?
Yes.

Do you know how I could achive the same thing from a separtate VB app
that controls word as a COM Automation object ?

Thanks again for your assistance

I guess that you would still need a template that would call your Add-in.
The call could pass the activeDocument as an object to the Add-in.

But I have never really work with pure VB add-in, wait, it won't be long
before someone else joins us!

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

Andrew Kennard

Jean-Guy

Thanks for your reply

Let's hope others join the party soon !

Cheers

Andrew
 
P

Perry

Any reason *not* to use the Doc Before Save event?


--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 
A

Andrew Kennard

The doc hasn't actullay been saved at that point and the user can cancel the
save or change the name of the doc in the case of SaveAs etc The save
operation just hasn't happend yet.

Regards

Andrew
 
A

Andrew Kennard

.... and if it is a new document first save then it wont even exist on disc

Regards

Andrew
 
A

Andrew Kennard

So not many people using word as a COM Automation object ? or is the lack of
"AfterEvents" just not a problem in you applications ?

Thanks

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top