2

I'm working on a Visual Studio 11 add-in. Through code, how can I detect when the current active document is saved? I don't know where to begin, and I couldn't find anything on the web about it.

Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187

1 Answers1

4

I was facing the same problem with a VS10-addin and found this solution, hope this works for you as well...

    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    {
        _applicationObject = (DTE2)application;
        _addInInstance = (AddIn)addInInst;
        // Hook save changes event

        _applicationObject.Events.DocumentEvents.DocumentSaved += DocumentEvents_DocumentSaved;

    }