2

I am currently in the process of creating Addin's and also converting our VBA projects to .NET addins. With the VBA applications, they would only work with specific MXD's. Is this possible to do with Addin's as well?

  • I am, by far, not an expert at add-ins, but one of the things that seems frustrating is that the add-ins seem like an "all or nothing" thing... I don't think you can turn it on or off for certain mxd's, etc. What you might have to do is write code that maybe checks the name of the mxd and then executes only if the name matches one in your pre-determined list. – Jason Miller Dec 2 '13 at 12:25
  • 2
    The AddIns aren't tied to a specific MXD, so you would have to enable/disable function based on some identifying information of the MXD, filename or maybe IDocumentInfo.Keywords. I think you could probably also implement persistence on the MXD if you needed more structured storage, but I've never had to do it for an AddIn. – Jay Cummins Dec 2 '13 at 13:43
2

You can write your add-in to only respond to events when a specific document is open. CoCreate an MxDocument in ArcMap, cast to IMapDocument and check the DocumentFilename property to see if it's a map document you plan on supporting. It's extra code, but it works.

  • As has been implied in the comments and this answer by Jason you really have no other option here aside from checking the name of the .MXD and validating it against some value. The downside to this is that if the user changes the name of the .MXD for whatever reason it will no longer work. There is unfortunately no unique identifier of a .MXD file independent of the file name that is exposed through ArcObjects. – Conor Dec 2 '13 at 17:45
0

You can always implement an application extension and persist any data in the MXD, including some kind of flag which would signify that other parts of your addin should be available for that particular document.

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.