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 attempting to Zoom from an Access record to a specific polygon in ArcMAP but I can't seem to get the function to work. The field in Access is identical to the field in arcmap. I.E. they both have a unique polygonID (custom field) identifier.

I have been able to open the specific record in Access from ArcMAP but would like the functionality to work both directions.

Does anyone know if there is any examples of this online and if it is even possible/worth doing with VBA being phased out.

Thanks

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

I assume you are talking about manipulating an active ArcMap session from outside the application boundary. To do this you need to use IAppROT to get a reference to the specific ArcMap application instance you want to manipulate. From there you can access its document, active view, map, etc. and manipulate them as needed (see @artwork21's answer).

Just be aware that any reference type objects that you create, especially singletons like factories, you must use IObjectFactory to create them within the ArcGIS application's process.

The Activate ArcCatalog from ArcMap sample shows how to use IAppROT to obtain a reference to ArcCatalog. You would need only to change it to look for ArcMap (IMxApplication) instead of ArcCatalog (IGxApplication) and remove the logic that starts ArcCatalog and waits for it to be added to the AppROT if that is not your intention.

You will likely also need to check out a license using IAoInitialize before creating the AppROT object.

Also worth noting, as an alternative to using VBA in Access, you could use ArcObjects in Python, and call the Python script from a macro in Access.

share|improve this answer
1  
+1 Good explanation. Also might include Sebastian's message pump hack. –  Kirk Kuykendall Apr 3 '12 at 18:46
    
Hmm. I would assume then with VBA being phased out that the python script route might be the best option for longevity? Would the ideal method for this route be to simply build the python script then insert my polygon value dynamically into the script? I am not fully familiar with Python but would Argv work for this? Thanks –  Cody Apr 3 '12 at 18:54
    
Yes you could use argv. You could also import arcpy which would handle the license checkout for you, and then use GetParameterAsText instead of argv. To be clear though, VBA is not being deprecated from Office by Microsoft, it is being deprecated from ArcGIS by ESRI. So you will be able to continue to use ArcObjects in VBA in Access to automate the ArcGIS applications, as this uses COM and that is not likely to go away anytime soon. –  blah238 Apr 3 '12 at 19:02
    
Yeah, I unfortunatly don't have Access to directly programming with the ArcObjects SDK. I have been unable to aquire this from my IT dept so this is the alternative route I am examining. By doing this method you should be able to open arcmap and zoom to the polygon via the python script correct? –  Cody Apr 3 '12 at 19:05
    
Also, i should clarify again that I am attempting to do this from a button click within Access. –  Cody Apr 3 '12 at 19:44
show 3 more comments

I would suggest to develop in Visual Studio and create an add-in.

You can use a query filter to select feature(s) and then call the Zoom to Selected arcmap command.

Zoom to Selected Command eg.

  Dim pUID As New UID
  Dim pCmdItem As ICommandItem
  ' Use the GUID of the Save command
  pUID.Value = "{AB073B49-DE5E-11D1-AA80-00C04FA37860}"
  ' or you can use the ProgID
  ' pUID.Value = "esriArcMapUI.ZoomToSelectedCommand"
  pUID.SubType = 3
  Set pCmdItem = My.ArcMap.Application.Document.CommandBars.Find(pUID)
  pCmdItem.Execute
share|improve this answer
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.