ArcObjects: Determine if an mxd file is loaded or currently open in ArcMap

4783
3
10-02-2014 12:34 PM
JamariPowers
New Contributor III

I am working with C# and ArcObjects. I am having trouble determining if an .mxd file is loaded or currently open. I have been looking at the IMapDocument and IMxDocument objects, as well as the IMapDocument.IsMapDocument property but I am not following. I am not able to mimic its functionality.

All I am trying to accomplish is a function that returns a boolean value or even a message saying 'Yes' if there is a map document loaded/opened and 'No' if a map document is not loaded/opened.

Any help on this topic would be greatly appreciated. Thanks in advance.

3 Replies
StefanOffermann
Occasional Contributor II

You should be able to check if the IApplication.Document property is null. If it is not null, a file is open. I haven't checked if this works, but this would be my approach.

JamariPowers
New Contributor III

I see. Thanks for your input. I'll take a look and experiment with this and see what I can come up with. Should be able to create and test a simple boolean function to see if it suits my needs.

0 Kudos
ShriramBhutada1
New Contributor III

Jamari,

Another way you can know if document is completely loaded is to listen IActiveViewEvents after opening a mxd document. For example, a map load event will be followed by a IActiveViewEvents.FocusMapChanged.

ArcObjects 10 .NET SDK Help

Thanks,

Shriram

0 Kudos