English

How To: Set a map document's properties using ArcObjects

Summary

In ArcMap, there is a Map Document Properties dialog that shows the following information fields about the .mxd file: Title, Summary, Description, Author, Credits, Tags and Hyperlink base.

The Map Document Properties dialog box

[O-Image]
Instructions provided describe how to access and changes these properties via the IDocumentInfo2 interface.

Procedure

The samples below show how to change the author, title, and description of the document.

  • VB.NET Sample

    Code:
    Dim pMapDoc As IMapDocument = New MapDocument()
    pMapDoc.Open("C:\\Untitled.mxd")
    Dim pDocInfo As IDocumentInfo2 = pMapDoc

    'Change the author of the document
    pDocInfo.Author = "Esri"

    'Change the title of the document.
    pDocInfo.DocumentTitle = "My Map Document"

    'Change the description of the document
    pDocInfo.Comments = "This is a demo."

    'Save the change
    pMapDoc.Save()

  • C# Sample

    Code:
    IMapDocument pMapDoc = new MapDocument();
    pMapDoc.Open("C:\\Untitled.mxd");
    IDocumentInfo2 pDocInfo = (IDocumentInfo2) pMapDoc;

    //Change the author of the document
    pDocInfo.Author = "Esri";

    //Change the title of the document.
    pDocInfo.DocumentTitle = "My Map Document";

    //Change the description of the document
    pDocInfo.Comments = "This is a demo.";

    //Save the change
    pMapDoc.Save();

  • JAVA Sample

    Code:
    IMapDocument pMapDoc = new MapDocument();
    pMapDoc.open("C:\\Untitled.mxd", "");
    IDocumentInfo2 pDocInfo = (IDocumentInfo2) pMapDoc ;

    //Change the author of the document
    pDocInfo.setAuthor("Esri");

    //Change the title of the document.
    pDocInfo.setDocumentTitle ("My Map Document");

    //Change the description of the documentpDocInfo.setComments ("This is a demo.");

    //Save the change
    pMapDoc.save(false, false);

Related Information