Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have the following code. When saving, closing or opening, the application events are triggered, but the change event does not. Does anyone have a clue?
public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
{
try
{
// Initialize AddIn members.
Globals.invApp = addInSiteObject.Application;
Globals.invApp.ApplicationEvents.OnDocumentChange += onChange;
Globals.invApp.ApplicationEvents.OnSaveDocument += onSaving;
Globals.invApp.ApplicationEvents.OnCloseDocument += onClosing;
Globals.invApp.ApplicationEvents.OnOpenDocument += onOpen;
}
catch (Exception ex)
{
MessageBox.Show("Unexpected failure in the activation of the add-in " + System.Environment.NewLine + System.Environment.NewLine + ex.Message);
}
}
private bool isSaving = false;
private void onChange(_Document DocumentObject, EventTimingEnum BeforeOrAfter, CommandTypesEnum ReasonsForChange, NameValueMap Context, out HandlingCodeEnum HandlingCode)
{
if (BeforeOrAfter == EventTimingEnum.kAfter)
{
MessageBox.Show("Hello");
}
HandlingCode = HandlingCodeEnum.kEventNotHandled;
}
private void onOpen(_Document DocumentObject, string FullDocumentName, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
{
if (BeforeOrAfter == EventTimingEnum.kAfter)
{
MessageBox.Show("Hello");
isSaving);
}
HandlingCode = HandlingCodeEnum.kEventNotHandled;
}
private void onClosing(_Document DocumentObject, string FullDocumentName, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
{
if (BeforeOrAfter == EventTimingEnum.kBefore)
{
MessageBox.Show("Hello");
}
HandlingCode = HandlingCodeEnum.kEventNotHandled;
}
private void onSaving(_Document DocumentObject, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
{
if (BeforeOrAfter == EventTimingEnum.kBefore)
{
MessageBox.Show("Hello");
}
HandlingCode = HandlingCodeEnum.kEventNotHandled;
}
Solved! Go to Solution.