Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
1  
Have you quoted the error message exactly? –  whuber Jan 9 '13 at 19:47
2  
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? help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… –  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
add comment

2 Answers 2

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"")
pApp.RefreshWindow
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
add comment

It is not tested

string cboStations;
string cboDistrict;

ESRI.ArcGIS.Framework.IApplication theMap = ArcMap.Application;
if (cboDistrict == "Abilene") 
   theMap.OpenDocument(@"K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\District_Maps\2012\Abilene\Abil‌​ene_Base_Map.mxd"); 

EDIT :
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
add comment

Your Answer

 
discard

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.