ArcObjects Library Reference (Controls)  

IMapControl3.LoadMxFile Method

Loads the specified Map from the map document into the MapControl. The Map can be an index or a name, if it is not supplied the focus map is used.

[Visual Basic .NET]
Public Sub LoadMxFile ( _
    ByVal mxPath As String, _
    [ByVal mapNameOrIndex As Object], _
    [ByVal password As Object] _
)
[C#]
public void LoadMxFile (
    string mxPath,
    object mapNameOrIndex,
    object password
);
[C#]

Optional Values

mapNameOrIndex   To indicate that this parameter is undefined, pass in Type.Missing.
password   To indicate that this parameter is undefined, pass in Type.Missing.
[C++]
HRESULT LoadMxFile(
  BSTR mxPath,
  VARIANT mapNameOrIndex,
  VARIANT password
);
[C++]

Parameters

mxPath [in]   mxPath is a parameter of type BSTR mapNameOrIndex [optional]   mapNameOrIndex is a parameter of type VARIANT

  To indicate this parameter is undefined pass in a VARIANT with type VT_ERROR and scode value of DISP_E_PARAMNOTFOUND.

password [optional]   password is a parameter of type VARIANT

  To indicate this parameter is undefined pass in a VARIANT with type VT_ERROR and scode value of DISP_E_PARAMNOTFOUND.

Product Availability

Available with ArcGIS Engine.

Description

Loads an map Document into the MapControl. The map document can be an ArcMap document, an ArcMap template or an ArcReader document. Use the CheckMxFile method to determine  if the specified map document is a valid map document.

Errors Returned

1018 800a03fa: The specified filename is invalid, the contents are corrupt or invalid
1019 800a03fb: The specified filename cannot be found
1020 800a03fc: The specified filename is invalid, the file cannot be opened
1021 800a03fd: The specified document has timed out
1024 800a0400: The specified map or index parameter is not a valid type
1031 800a0407: Password required to read this map document
1032 800a0408: The specified password is incorrect
1033 800a0409: The password parameter does not contain a valid string
1043 800a0413: The version of the specified document cannot be read by this software
1044 800a0414: The specified document can only be opened in the ArcReader application
1045 800a0415: The specified document does not allow access to internal objects
1065 800a0429: The specified Published Map File contains a Globe and cannot be open

Remarks

When LoadMXfile is used the user may be prompted for a password; refer to the tables below to determine when this may occur. Additionally, password prompts may be given if accessing MapDocuments using either the MapControl's PropertyPage, ArcMap or ArcReader; the tables also show in what circumstances this will occur.

Loading Map Documents (*.mxd, *.mxt, *.pmf) which reference IMS Services (with and without security)

Application No Secure Services MXD/ MXT/ PMF files Secure Servcies MXD/ MXT/ PMF files Secure Servcies (password cached) MXD/ MXT files Secure Servcies (password cached) PMF files
MapControl (programmatically) No Prompt Prompt No Prompt Prompt
MapControl (property pages) No Prompt Prompt No Prompt Prompt
ArcMap No Prompt Prompt No Prompt Prompt
ArcReader (PMF files only) No Prompt Prompt N/A No Prompt

* The Connection to the Internet server must have the Save User/ Password setting enabled. This can be set, for example, when using Add Internet Server in the Add Layers Dialog. Additionally, in the case of PMF files the ArcPublisher Cache password in PMF file setting must be enabled.

Loading Published Map Files (*.pmf) (with and without password protection)

Application PMF with No Password PMF with Password
MapControl (programmatically) No Prompt Supply in Code
MapControl (property pages) No Prompt Prompt
ArcMap No Prompt Prompt
ArcReader No Prompt Prompt

See Also

IMapControl3 Interface | IMapControl2.CheckMxFile Method | IMapControl4.CheckMxFile Method | IMapControl3.CheckMxFile Method | IMapControl3.ReadMxMaps Method | IMapControl4.ReadMxMaps Method | IMapControl2.ReadMxMaps Method

.NET Samples

Using MOLE symbol-based graphics with interactive maps (Code Files: MainForm) |