Select to view content in your preferred language

How to get map description using vb.net

757
2
Jump to solution
02-27-2013 09:59 AM
JamesFinlay
New Contributor
Good day,

I am currently trying to figure out how to access a MapDocument's description as set in the File > Map Document Properties. I am trying to access it through a VB.NET add-in. The image below shows the description field I am referring to:

[ATTACH=CONFIG]22221[/ATTACH]


I found it easy enough to access the basic info here, such as the Title, but I cannot find a way to get the description programmatically. Here is the code I have to get the Map Document Title:

 ' Open Map Document Info Dim theMapDoc As IMapDocument = New MapDocument theMapDoc.Open("TheFileName.mxd") Dim theDocInfo As IDocumentInfo = TryCast(theMapDoc, IDocumentInfo)  Dim FileTitle as String = theDocInfo.DocumentTitle


I found that the IMap interface has a Description field, but from what I tried it doesn't seem to be the same one as in the form.
I was searching around online, but I cannot find any help in reading the Description field. Any help would be greatly appreciated.

Thanks in advance!
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
The IDocumentInfo2 interface exposes much more information.

        Dim pMapDocument As New ESRI.ArcGIS.Carto.MapDocument         pMapDocument.Open("TheFileName.mxd")          Dim pDocInfo As ESRI.ArcGIS.Carto.IDocumentInfo2 = TryCast(pMapDocument, ESRI.ArcGIS.Carto.IDocumentInfo2)          Debug.Print(pDocInfo.Author.ToString & vbNewLine &                      pDocInfo.Category.ToString & vbNewLine &                      pDocInfo.Comments.ToString & vbNewLine &                      pDocInfo.Credits.ToString & vbNewLine &                      pDocInfo.DateExported.ToString & vbNewLine &                      pDocInfo.DatePrinted.ToString & vbNewLine &                      pDocInfo.DateSaved.ToString & vbNewLine &                      pDocInfo.DocumentTitle.ToString & vbNewLine &                      pDocInfo.Folder.ToString & vbNewLine &                      pDocInfo.HyperlinkBase.ToString & vbNewLine &                      pDocInfo.Keywords.ToString & vbNewLine &                      pDocInfo.Name.ToString & vbNewLine &                      pDocInfo.Path.ToString & vbNewLine &                      pDocInfo.RelativePaths.ToString & vbNewLine &                      pDocInfo.SavePreview.ToString & vbNewLine &                      pDocInfo.Subject.ToString                      )


The description is given in the Comments property.

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor
The IDocumentInfo2 interface exposes much more information.

        Dim pMapDocument As New ESRI.ArcGIS.Carto.MapDocument         pMapDocument.Open("TheFileName.mxd")          Dim pDocInfo As ESRI.ArcGIS.Carto.IDocumentInfo2 = TryCast(pMapDocument, ESRI.ArcGIS.Carto.IDocumentInfo2)          Debug.Print(pDocInfo.Author.ToString & vbNewLine &                      pDocInfo.Category.ToString & vbNewLine &                      pDocInfo.Comments.ToString & vbNewLine &                      pDocInfo.Credits.ToString & vbNewLine &                      pDocInfo.DateExported.ToString & vbNewLine &                      pDocInfo.DatePrinted.ToString & vbNewLine &                      pDocInfo.DateSaved.ToString & vbNewLine &                      pDocInfo.DocumentTitle.ToString & vbNewLine &                      pDocInfo.Folder.ToString & vbNewLine &                      pDocInfo.HyperlinkBase.ToString & vbNewLine &                      pDocInfo.Keywords.ToString & vbNewLine &                      pDocInfo.Name.ToString & vbNewLine &                      pDocInfo.Path.ToString & vbNewLine &                      pDocInfo.RelativePaths.ToString & vbNewLine &                      pDocInfo.SavePreview.ToString & vbNewLine &                      pDocInfo.Subject.ToString                      )


The description is given in the Comments property.
0 Kudos
JamesFinlay
New Contributor
The IDocumentInfo2 interface exposes much more information.

        Dim pMapDocument As New ESRI.ArcGIS.Carto.MapDocument
        pMapDocument.Open("TheFileName.mxd")

        Dim pDocInfo As ESRI.ArcGIS.Carto.IDocumentInfo2 = TryCast(pMapDocument, ESRI.ArcGIS.Carto.IDocumentInfo2)

        Debug.Print(pDocInfo.Author.ToString & vbNewLine &
                     pDocInfo.Category.ToString & vbNewLine &
                     pDocInfo.Comments.ToString & vbNewLine &
                     pDocInfo.Credits.ToString & vbNewLine &
                     pDocInfo.DateExported.ToString & vbNewLine &
                     pDocInfo.DatePrinted.ToString & vbNewLine &
                     pDocInfo.DateSaved.ToString & vbNewLine &
                     pDocInfo.DocumentTitle.ToString & vbNewLine &
                     pDocInfo.Folder.ToString & vbNewLine &
                     pDocInfo.HyperlinkBase.ToString & vbNewLine &
                     pDocInfo.Keywords.ToString & vbNewLine &
                     pDocInfo.Name.ToString & vbNewLine &
                     pDocInfo.Path.ToString & vbNewLine &
                     pDocInfo.RelativePaths.ToString & vbNewLine &
                     pDocInfo.SavePreview.ToString & vbNewLine &
                     pDocInfo.Subject.ToString
                     )


The description is given in the Comments property.


That's exactly what I needed. I hadn't realized it was in the Comments property. Thank you very much for the help.
0 Kudos