Listen for 'Save', 'Save As' and 'Save A Copy' in ArcMap

580
1
08-07-2013 07:16 AM
AndrewCorcoran
New Contributor III
I need to differentiate between the 3 save commands in ArcMap using ArcObjects.

I've created an application extension which overrides the OnSave(Stream stream) method but this is triggered when either:

Save
Save As...
Save A Copy...

is selected. Any idea how I work out which one was selected?
0 Kudos
1 Reply
AndrewCorcoran
New Contributor III
For anyone interested, I figured out a way to do it by making my application extension implement ICustomizationFilter. Here is the OnCustomizationEvent method I use:

public Boolean OnCustomizationEvent(esriCustomizationEvent e, Object context)
{
    if (e == esriCustomizationEvent.esriCEInvokeCommand && context is ICommandItem)
        m_currentCommandId = ((ICommandItem)context).ID;
            
    // Always return false - we don't want the UI locked.
    // Just need to know the last command triggered
    return false;
}


Then in the OnSave method I can check to see if the m_currentCommandId UID is {119591DB-0255-11D2-8D20-080009EE4E51} and the sub-type is 3 which is the ID and sub-type for 'Save...'. The full list of UID values and sub-types can be found here.
0 Kudos