HowTo:  Set a map document's properties using ArcObjects

相关信息
Article ID: 40759
Software:
ArcObjects SDK for the Microsoft .NET Framework 10.0, 10.1
ArcObjects SDK for Java Linux 10.0, 10.1
ArcObjects SDK for Java Windows 10.0, 10.1
Platforms:
Windows Windows 7

问题描述
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.



Instructions provided describe how to access and changes these properties via the IDocumentInfo2 interface.
已邀请:

EsriSupport

赞同来自:

解决方案
The samples below show how to change the author, title, and description of the document.
1.VB.NET Sample 
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()
2.C# Sample ​
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();
3.JAVA Sample 
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);

其它相关参考
  1. IDocumentInfo2 Interface


创建及修改时间
Created: 12/19/2012

Last Modified: 1/17/2013
原文链接
http://support.esri.com/en/kno ... 40759

要回复问题请先登录注册