I'm trying to get a reference to the current MXD so I can save it to disk before making a backup copy. I tried the following snippet from inside a BaseCommand class I created.
IMapDocument mapDoc = m_application.Document as IMapDocument;
mapDoc.Save(mapDoc.UsesRelativePaths, false);
This is how the ESRI examples show it working, but I get a null reference on mapDoc each time. The MXD is loaded and I can get IMxDocument just fine. I can't save that though, I need IMapDocument.
Using the current ArcMap document as IMapDocument only works in ArcGIS 10.0. You will need to use a combination of IApplication and IApplication.Document (as IMxDocument) to accomplish this.