1

I have an MS Access front-end that can be used to open ArcGIS map documents (.mxds).

It has a macro that runs an OpenRoadMap() function:

enter image description here

 Function OpenRoadMap()
     CreateObject("Shell.Application").Open ("{your path here}\ROAD.mxd")  
 End Function

Problem:

The .mxd connects to the database just fine when I open it manually.

However, when I open the map using the VBA script, the map is unusable because it is unable to connect to the database:

enter image description here

enter image description here

Why is the VBA-opened .mxd unable to connect to the database?

  • Windows 7 Enterprise - Service Pack 1
  • Microsoft Access 2010
  • ArcGIS 10.3.1
  • Oracle 12c
  • A useful, but unrelated tip: To open vba code from a RunCode macro, the vba must be a function, not a procedure. However, it's not necessary to actually pass the function a variable (you can treat it as if it were a procedure). stackoverflow.com/a/17244981/5576771 – Wilson Nov 10 '17 at 14:42
1

There appear to be several different ways to open files with VBA.

When the file is opened using this alternative method, the map is able to connect to the database successfully:

Function OpenRoadMap()
    Shell "explorer.exe {your path here}\ROAD.mxd"
End Function

It seems to be using Windows Explorer (explorer.exe) to open the file. I guess going indirectly through Windows Explorer is is somehow avoiding the database connections being disabled.

I couldn't say why this technique works over the other one. Maybe some VBA libraries have different security settings than others?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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