Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2007

Tip: Looking for answers? Try searching our database.

AfterSave Event ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew Kennard - 22 May 2007 09:15 GMT
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
Jean-Guy Marcil - 22 May 2007 16:26 GMT
Andrew Kennard was telling us:
Andrew Kennard nous racontait que :

> Hi all
>
[quoted text clipped - 10 lines]
>
> 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
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Andrew Kennard - 22 May 2007 16:39 GMT
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

> Andrew Kennard was telling us:
> Andrew Kennard nous racontait que :
[quoted text clipped - 68 lines]
> End Sub
> '_______________________________________
Jean-Guy Marcil - 22 May 2007 16:53 GMT
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!

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Andrew Kennard - 23 May 2007 09:38 GMT
Jean-Guy

Thanks for your reply

Let's hope others join the party soon !

Cheers

Andrew

> Andrew Kennard was telling us:
> Andrew Kennard nous racontait que :
[quoted text clipped - 26 lines]
> But I have never really work with pure VB add-in, wait, it won't be long
> before someone else joins us!
Perry - 29 May 2007 22:10 GMT
Any reason *not* to use the Doc Before Save event?

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE

> Jean-Guy
>
[quoted text clipped - 36 lines]
>> But I have never really work with pure VB add-in, wait, it won't be long
>> before someone else joins us!
Andrew Kennard - 31 May 2007 09:29 GMT
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

> Any reason *not* to use the Doc Before Save event?
>
[quoted text clipped - 47 lines]
>>> But I have never really work with pure VB add-in, wait, it won't be long
>>> before someone else joins us!
Andrew Kennard - 31 May 2007 11:37 GMT
... and if it is a new document first save then it wont even exist on disc

Regards

Andrew

> 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
[quoted text clipped - 55 lines]
>>>> But I have never really work with pure VB add-in, wait, it won't be
>>>> long before someone else joins us!
Andrew Kennard - 05 Jun 2007 10:13 GMT
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

> ... and if it is a new document first save then it wont even exist on disc
>
[quoted text clipped - 61 lines]
>>>>> But I have never really work with pure VB add-in, wait, it won't be
>>>>> long before someone else joins us!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.