Events in Visual Studio Tools for Office


Several events are found on VSTO objects that are not found when using the Word primary interop assembly (PIA) alone. Table 7.1 lists these events. Almost all events are from the Word PIA that are raised again on different objects. In the Word PIA, there is no BeforeSave event on the Document, for example, but there is a DocumentBeforeSave event on the Application object that passes as a parameter the Document that is about to be saved. VSTO adds a BeforeSave event to the Document object for Word. The Document object's BeforeSave event is raised whenever the Application object's DocumentBeforeSave event is raised with the given Document object as a parameter.

Table 7.1. Events That Are Added in VSTOEvents

Events

Raised Again From

Document Object

 

ActivateEvent

Application.WindowActivate

BeforeClose

Application.DocumentBeforeClose

BeforeDoubleClick

Application.WindowBeforeDoubleClick

BeforePrint

Application.DocumentBeforePrint

BeforeRightClick

Application.WindowBeforeRightClick

BeforeSave

Application.DocumentBeforeSave

CloseEvent

Renamed Document.Close event to prevent collisions

Deactivate

Application.WindowDeactivate

MailMergeAfterMerge

Application.MailMergeAfterMerge

MailMergeAfterRecordMerge

Application.MailMergeAfterRecordMerge

MailMergeBeforeMerge

Application.MailMergeBeforeMerge

MailMergeBeforeRecordMerge

Application.MailMergeBeforeRecordMerge

MailMergeDataSourceLoad

Application.MailMergeDataSourceLoad

MailMergeWizardSendToCustom

Application.MailMergeWizardSendToCustom

MailMergeWizardStateChange

Application.MailMergeWizardStateChange

SelectionChange

Application.WindowSelectionChange

Startup

New event raised by VSTO

Shutdown

New event raised by VSTO

SyncEvent

Renamed Document.Sync event to prevent collisions

WindowSize

Application.WindowSize

Bookmark Object

 

BeforeDoubleClick

Application.WindowBeforeDoubleClick

BeforeRightClick

Application.WindowBeforeRightClick

Deselected

Application.WindowSelectionChange

Selected

Application.WindowSelectionChange

SelectionChange

Application.WindowSelectionChange

XMLNode Object

 

AfterInsert

Document.XMLAfterInsert

BeforeDelete

Document.XMLBeforeDelete

ContextEnter

Application.XMLSelectionChange

ContextLeave

Application.XMLSelectionChange

Deselect

Application.WindowSelectionChange

Select

Application.WindowSelectionChange

ValidationError

Application.XMLValidationError

XMLNodes Object

 

AfterInsert

Document.XMLAfterInsert

BeforeDelete

Document.XMLBeforeDelete

ContextEnter

Application.XMLSelectionChange

ContextLeave

Application.XMLSelectionChange

Deselect

Application.WindowSelectionChange

Select

Application.WindowSelectionChange

ValidationError

Application.XMLValidationError


Another case where VSTO changes events is in the naming of the Close event and the Sync event on the Document object. Both of these event names conflict with method names on Document. To avoid this conflict, VSTO renames these events CloseEvent and SyncEvent.

VSTO adds events to some objects that have no events at all in the Word PIA. These objects include Bookmark, XMLNode, and XMLNodes. Table 7.1 lists the events added to these objects. You can determine what a particular event does by reading the documentation for the event from which it is raised again.




Visual Studio Tools for Office(c) Using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath
Visual Studio Tools for Office: Using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath
ISBN: 0321411757
EAN: 2147483647
Year: N/A
Pages: 221

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net