Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working in VBA. My error is sub and function are not defined. Here is my code:

Private Sub CreateMap(cboDistrict As String)   
    Dim mapDocument As New mapDocument
    If mapDocument.IsPresent("K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\District_Maps\2012\Abilene\Abilene_Base_Map.mxd") Then
        mapDocument.Open ("K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\District_Maps\2012\Abilene\Abilene_Base_Map.mxd")
    End If
End Sub

I am trying to open an mxd when the Map button is pushed.

share|improve this question
Have you quoted the error message exactly? – whuber Jan 9 '13 at 19:47
I'm not the one who downvoted your question, but I suspect whoever did, felt the question might be better suited for StackOverflow. Maybe this answer addresses your issue. Try putting Call in front of the mapDocument.Open. – Kirk Kuykendall Jan 9 '13 at 21:43
are you running if from an opened Mxd? on which line do you get error? pls post more info.. – vinayan Jan 10 '13 at 5:38
Are you using "IMapDocument.Open" method? Doesn't it get two parameters?… – Emi Jan 15 '13 at 4:41
is there a question here? What is the error message you get? – vinayan Jan 15 '13 at 8:27

I think the usage should be

Dim mapDocument As IMapDocument
set mapDocument = New MapDocument

 If mapDocument.IsPresent ....

One more thing you can try

Dim pDoc As IDocument
Dim pApp As IApplication
Set pDoc = New MxDocument
Set pApp = pDoc.Parent
pApp.Visible = True
pApp.OpenDocument ("K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\District_Maps\2012\Abilene\Abilene_Base_Map.mxd"")
share|improve this answer
Would it be possible for you to add references to make your answer more authoritative? – R.K. Jan 10 '13 at 15:02

It is not tested

string cboStations;
string cboDistrict;

ESRI.ArcGIS.Framework.IApplication theMap = ArcMap.Application;
if (cboDistrict == "Abilene") 

Maybe you are getting this error because of calling a method with wrong number of parameters. Please go through IMapDocument.Open Method

share|improve this answer
... you are calling mapDocument.Open() method in a wrong way. The mapDocument.Open() method takes two arguments not one. – Emi Jan 15 '13 at 10:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.