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 have a dialog box written in ArcObjects.

I am programming the Map button on the dialog box.

The user picks a type of station and county.

The program goes to folder containing the mxds and opens the one with the same county name.

I need to know how to code for going to folder and then opening the mxd.

My program is listed below :

Dim pWorkspaceName As WorkspaceName
Set pWorkspaceName = New WorkspaceName
Dim pWorkspaceName2 As WorkspaceName2
Set pWorkspaceName2 = New WorkspaceName2
pWorkspaceName.PathName = "K:\TASS\4_MAPPING_DATA_Maps\2012"
pWorkspaceName.PathName2 = "K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\Urban_Maps"

Dim cboStations As String
If cboStations = "Annual" Then pWorkspaceName.PathName
Else
pWorkspaceName.PathName2


Dim districts As String
Dim cboDistrict As String

If cboDistrict = "Abilene" Then Application.OpenDocument ("K:\TASS\4_MAPPING\Abilene_Base_Map.mxd")
Elif
cboDistrict = "Amarillo" then getmxd "K:\TASS\4_ps\2012\Amarillo"
share|improve this question
2  
Are you getting an error when you try to run your application? Can you be more specific about the problem you are having? –  Kevin Jan 8 '13 at 17:07
1  
What is the intended logic, step by step? It is not clear from the code which does not appear to be functional or complete. –  blah238 Jan 8 '13 at 17:15

2 Answers 2

Here are two options:

   Dim mapDocument As New MapDocument()

   If mapDocument.isPresent(mapLocation) Then
        mapDocument.open(mapLocation, "")
   End If

AND

You can also use Shell command to open an mxd, see example below (example is not for opening ArcMap, however the concept is the same)

Launching a program/open a file through VBA

share|improve this answer
    
I am not getting an error because I haven't tried it yet. The logic is to Go to the folder that has the annual maps (they select from the drop down box to specify they want Annual stations so the program then goes to that folder, they also select county name from drop down box and then the program goes to the annual folder and grabs the county name mxd to open it so the user can then look at said map. So the program has to go to a folder first then pick out an mxd to open. –  Michelle Couden Jan 8 '13 at 17:42
    
The link doesn't help because I am not opening a different document. I am opening an mxd document. –  Michelle Couden Jan 8 '13 at 18:37
    
@Michelle Couden, You should be able to push the ArcMap.exe and specific mxd file into a Shell command. –  artwork21 Jan 8 '13 at 19:41

There is a code for Open New Map Document. You can go through this. But it did not work for me.

I have done following code for me. I have no idea about VB. So, I am posting this code in c#. I hope you can convert it for yourself.

void OpenMxd(string mxdPath)
{
    IMapDocument mapDoc = new MapDocumentClass();
    if (mapDoc.IsPresent[mxdPath] && mapDoc.IsMapDocument[mxdPath] && !mapDoc.IsPasswordProtected[mxdPath])
    {
        mapDoc.Open(mxdPath);
        IMap map = mapDoc.Map[0];
        ArcMap.Document.ActiveView = map as IActiveView;
        mapDoc.Close();
    }
}
share|improve this answer
    
@Michelle Couden, Does this work for you? –  Emi Jan 30 '13 at 10:58

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.