PDA

View Full Version : Ribbon Addin not closing when Main Addin closes



Charlie Hall
12-17-2009, 08:47 AM
Hi,

I have a 2003 Addin that I am adding a ribbon interface to. Having purchased the RibbonX book I am following chapter 16 on sharing and deploying. I have created a 2007 Addin that just has the ribbon and launching code. However, when I close the 2003 Addin, the 2007 Addin does not close.

Specicifically, in the 2003 Workbook_BeforeClose event, I call a routine that issues a Workbooks.close command of the 2007 Addin. If I call the routine via the Immediate window, the 2007 addin closes. But if I close the 2003 addin via the Immediate window (thisworkbook.close), the routine is called but the 2007 addin remains open.

Since my code is so similar to the code in the book I am having a hard time understanding why it does not work. I also stripped out the ribbon code, and the problem remains.

Any insight would be greatly appreciated.

Thanks
--Charlie

Bob Phillips
12-17-2009, 09:43 AM
Can you post the workbook?

Charlie Hall
12-17-2009, 10:23 AM
Here are the two addins

Charlie Hall
12-21-2009, 05:57 PM
Any insight into why my implementation of the code in the RibbonX book is not working? Any help will be appreciated. Thanks
--Charlie

Ken Puls
12-29-2009, 03:03 PM
Hi Charlie,

I changed your Workbook_Open code (2003 version) to the following:
Private Sub Workbook_Open()
Dim wBook As Workbook, rFound, wb As Workbook, sWbPath As String
'if 2007 or later, find ribbon addin and launch if not already loaded, else load toolbar
RibbonAddin_gs = Replace$(theAddIn, theAddinBase, theAddinBase & RibbonBaseSuffix_gsC)
RibbonAddin_gs = Replace$(RibbonAddin_gs, xla, xlam)
' check if ribbon addin is already loaded
On Error Resume Next
Set wb = Nothing
wb = Workbooks(RibbonAddin_gs)
On Error GoTo 0
If wb Is Nothing Then
' ribbon addin not loaded, so do so
sWbPath = ThisWorkbook.Path & Application.PathSeparator & RibbonAddin_gs
If Dir(sWbPath) = RibbonAddin_gs Then
Workbooks.Open sWbPath
End If
End If
End Sub

FYI, for whatever reason you need to close Excel and re-open it to load the add-in properly. If you have the add-ins dialog open and are using that to test the install it doesn't seem to work (at least not for me).

Hope that helps,