How do I get the VBA modules that are linked to the current display?
I have a utility function in my C# addin called LoadVBAModule that checks whether the given module is loaded and, if not, loads it. The trouble is, if there are 2 displays open and one of them has the module loaded, it fails to get the other display. Both displays are new and may not have been saved at this point. Here's the relevant part of my function:
// Here I want to find the project relating to the active (or a provided) display
foreach (VBIDE.VBProject tmpVBProj in m_VBEnv.VBProjects)
VBProj = tmpVBProj;
if (VBProj == null)
Utils.ShowMsg(0, "LoadVBAModule()", "Failed to load VB project");
// Don't reload it if it's already there
foreach ( VBIDE.VBComponent tmpVBComp in VBProj.VBComponents)
if (tmpVBComp.Name == moduleName)
It's the first bit that I want to change so that it stops when it gets to the project relating to the active (or a specific) display but I can't see anything in the project properties that gives me that.