ArcObjects Library Reference (Carto)  

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] _
)
[C#]
public void Open (
    string sDocument,
    string bsPassword
);
[C#]

Optional Values

bsPassword   Supply as a default value.
[C++]
HRESULT Open(
  BSTR sDocument,
  BSTR bsPassword
);
[C++]

Parameters

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.

Description

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. 

Remarks

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 (Code Files: frmMain) | Simple dynamic display application (Code Files: MainForm) | Implementing a property page for an ArcGIS Engine application (Code Files: frmMain) | Save a layer file in a MapControl application (Code Files: frmMain) | Schematics Engine application (Code Files: MainForm) | Temporal statistics (Code Files: MainForm)

.NET Related Topics

How to add a layer to a map from a layer file | How to create a mosaic layer