This document is archived and information here might be outdated.  Recommended version.

IMapDocument.Open Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IM > IMapDocument Interface > IMapDocument.Open Method
ArcGIS Developer Help

IMapDocument.Open Method

Open the map document in preparation for the contents to be retrieve or updated.

[Visual Basic .NET]
Public Sub Open ( _
    ByVal sDocument As String, _
    [ByVal bsPassword As String] _
public void Open (
    string sDocument,
    string bsPassword
  BSTR sDocument,
  BSTR bsPassword
sDocument [in]

sDocument is a parameter of type BSTR bsPassword [in, optional, defaultvalue()]
bsPassword is a parameter of type BSTR

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


Opens the specified MapDocument in preparation for reading it. The MapDocument can be an an ArcMap document (*.mxd), ArcMap template (*.mxt), Published Map File (*.pmf) or Layer File (*.lyr). The MapDocument will be cached so no other users will be able to access the MapDocument until it has been closed. 

Before using the Open methods check whether the specified document IsPresent, IsRestricted, IsMapDocument and IsPasswordProtected. If the MapDocument is password protected, specify the password in the Open method.  

If a Layer File (*.lyr) is opened a portriat PageLayout containing one Map with the layer added to it is created. 


When opening or creating a map document with the IMapDocument Open() or New() methods, you should always make subsequent calls to IActiveView::Activate() in order to properly initialize the display of the PageLayout and Map objects.  Call Activate() once for the PageLayout and once for each Map you will be working with.  If your application has a user interface, you should call Activate() with the hWnd of the application's client area.  If your application runs in the background and has no windows, you can always get a valid hWnd from the GDI GetDesktopWindow() function, part of the Win32 API.

See Also

IMapDocument Interface

.NET Samples

Synchronized MapControl and PageLayoutControl application Save a layer file in a MapControl application Simple dynamic display application Schematics Engine application Temporal statistics Temporal statistics