Select to view content in your preferred language

save map document

5508
10
02-01-2011 06:05 AM
TanaHaluska
Emerging Contributor
Hello
I am new to VB and .NET, can anyone tell me what I am doing wrong?  I am using arcmap v10 with MS Visual Studio Express 2008.  I just want to save my map document without presenting a dialog box to the user. The code snippet below does not produce an error, but the map document does not get saved either. Thanks
tlh

Dim pMxDoc As IMxDocument = DirectCast(m_app.document, IMxDocument)
Dim pMap As IMap = pMxDoc.FocusMap
Dim pMapDoc As IMapDocument = pMap
Dim mxdPathName As String

mxdPathName = strDefaultWorkspace & "\" & frmWSIn.txtMapDocName.Text
pMapDoc.SaveAs(mxdPathName)
0 Kudos
10 Replies
NeilClemmons
Honored Contributor
The first part of my post was explaining why your code wasn't working.  The last statement was saying you didn't need to do any of that and to use the IApplication methods.  m_app is your IApplication reference.  It has a Save and SaveAs method that you can call.  There's no need to use IMapDocument at all.
0 Kudos