James, that's quite easy actually. You only have to check the necessary ArcObject libraries in the Tools - References menu (ESRICarto UI Object library etc.) within the VBA environment in MSAccess and then you can use all ArcObject functions, methods and so on within Access - of course you'll need some ArcMap App that's running at the same time that your code interacts with. All that works - but for the export I mentioned.Daniel
Yeah, it's quite neat to run ArcMap from somewhere else ... the pPageLayout is obtained in other parts of the code, where I check if the ArcMap App is running and if so I get the IMxDoc::PageLayout from this App. This seems to work since if I do something with this pPageLayout - e. g. change the Zoom Factor - in Access ArcMap responds ok. But still - I too have a hunch that this reference to the PageLayout could be the problem but I can't think of another method to verify or change this!
Your code is not running inside of ArcMap. Therefore, any ArcObjects you create using the NEW keyword are created outside of ArcMap's process space. ArcObjects are single apartment threaded, meaning they will not marshal correctly across process boundaries. In order to work correctly, you will need to create all instances of the ArcObjects you're using inside of ArcMap's process space. This can be done by using IObjectFactory.
Type t = Type.GetTypeFromProgID("esriFramework.AppRef"); System.Object obj = Activator.CreateInstance(t); ESRI.ArcGIS.Framework.IApplication pApp = obj as ESRI.ArcGIS.Framework.IApplication;
I know a rather similar topic has been around before, but without a really satisfying answer, so I'll try again.I wrote a short export routine in VBA that simply exports the current PageLayout to a PDF file, and if run from within ArcMap it works fine. But if I put the same function in a module in MSAccess and run it from there it produces a blank page (of the right dimensions, however). All other ArcMap automation run from MSAccess works ok, e. g. if I set the layout zoom factor to 100 or refresh the page layout, that's done. Only the export itself produces a blank page.The actual code is attached although as I said it's working in ArcMap. I very much hope someone out there has a solution - thanks in advance.Daniel
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.