0

I am trying to open an mxd in an ESRI ArcMap add-in using vb.net. The user starts with a blank mxd and runs a tool to open an mxd that is stored in a file. The mxd that is opened by the code has some feature layers and some graphics in the layout.

So far I have:

Dim mapdoc As IMapDocument = New MapDocumentClass()
mapdoc.Open("D:\__Test\LockItInPMAV.mxd")

The document opens because I can get its filename via:

MsgBox("Filename: " & mapdoc.DocumentFilename)

However the data view and layout view remain blank, they do not show the contents of the opened file.

How can I get the opened file to display in the current ArcMap session?

Thanks, Luke.

Luke
  • 1
  • 1
  • Thanks to ESRI I'm using the right code now: My.ArcMap.Application.OpenDocument("D:\__Test\LockItInPMAV.mxd") However the rest of my code (adding layers to the TOC) runs through before the document is opened. The mxd doesn't open until my add in closes. Any ideas? – Luke Feb 18 '15 at 04:41
  • 2 weeks later and no replies and I still haven't solved this problem :( – Luke Mar 03 '15 at 05:51

1 Answers1

0

I'm working in C#. I'm not sure if you can load an mxd after it is loaded. You would either need to load a new arcmap instance and pass the mxd name as a parameter:

var expanPath = Environment.GetEnvironmentVariable(Properties.Settings.Default.arcmapLaunchPath, 
EnvironmentVariableTarget.Machine);

string Cmd = string.Format(@"{0}\arcmap.exe", expanPath);
ProcessStartInfo startInfo = new ProcessStartInfo(Cmd);
startInfo.Arguments = Properties.Settings.Default.MxDPath;

Process.Start(startInfo);           
Process.GetCurrentProcess().Kill();

The MXD holds so much details on how the instance of arcmap operates that it is not easy to reload it. Our esri contractor confirmed this.

I am told that Pro, has changed this completely.

Omnia9
  • 1,563
  • 4
  • 14
  • 39