View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
John[_130_] John[_130_] is offline
external usenet poster
 
Posts: 11
Default COM addin won't connect when workbook opened via another workbookfrom another instance

Hi, Garry. The addin is under HKCU. I'd already tried toggling .connect but get the same behavior---shows up in the addins checked and loaded. I run the same workbook on another machine (my windows 7 VM), and it works perfectly. The original workbook initiates a new excel session, opens WB, and loads COM addin. For some reason, this is not what happens at work where Excel in on a windows server. Registry appears to be consistent between the VM and server (HKCU).




On Wednesday, February 11, 2015 at 11:44:04 PM UTC-8, GS wrote:
I have two workbooks each in its own instance. One workbook opens the
other and needs to load a COM addin. The problem is the addin is not
being loaded. Well, it is checked in the addins and load behavior is
"load at startup", but the ribbon (and functionality) is not present.

However, when I active use the connect statement below inside the
workbook open event AND open the workbook myself everything loads as
desired. When the original workbook opens the workbook with this same
connect in the open event, nothing happens.

Application.COMAddIns("MyStuff.Addin.1").Connect = True

How can I get the first workbook to successfully open and
connect/activate/load this COM addin in the second workbook? I also
tried changing the default COM load behavior to always load---same
thing happens. Appears checked and loaded but no ribbon or
functionality.


By default, automated instances don't load addins nor enforce macro
security!

The connection of a COMAddin is always to the instance it's loaded
into. Thus each instance must load the COMAddin. If your 1st instance
automates the 2nd then no addins are loaded in the automated instance
unless the COMAddin is registered under HKLM, not HKCU. If your 1st
instance is also automated, then it also needs to load the COMAddin.

Just because the addin is checked, it doesn't mean it's loaded in an
automated instance. Try toggling .Connect False/True. If that doesn't
work then maybe the COMAddin doesn't support multiple instances of
itself.

Though 'Best Practice' encourages COMAddins be registered under HKCU,
not all developers follow 'Best Practices' in order to 'force' their
COMAddins to always install/load!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion