Displaying a custom ribbon tab using XLAM

perp1exed

New Member
Joined
Oct 28, 2011
Messages
20
Hi,

I created an XLAM file which displays a customized ribbon tab, the buttons of which call various macros.

How do I get this add-in file to load automatically when opening another xlsm file?

Currently, the only way to display the add-in ribbon is to open the XLAM file first, then open the other XLSM file.

Many thanks,

KS
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
put the file in the xlstartup folder
 
Upvote 0
put the file in the xlstartup folder

Thanks for your reply. I put the XLAM here:

C:\Program Files (x86)\Microsoft Office\Office14\STARTUP

When I open my xlsm file I do not see the ribbon and the add-in button on the developer tab is disabled (although i think that is by default)

thanks.
 
Upvote 0
Or put the addin in your addins folder and then install it as you would any addin
http://peltiertech.com/WordPress/installing-an-add-in-in-excel-2007/

Thanks, that worked. However my particular scenario is causing other issues.

From the xlsm file I am running macros which enable/disable buttons on the xlam file's custom tab.

When using this AddIns set up, the reference to the ribbon seems to be lost and I can no longer enable/disable the buttons.

This worked well when i was manually opening the xlam before the xlsm.

Anyway, I will look into this.

Thanks again!
 
Upvote 0
My ribbon.xlam


Code:
Option Explicit

Dim Rib As IRibbonUI
Public MyTag As String

'Callback for customUI.******
Sub Ribbon******(ribbon As IRibbonUI)
    Set Rib = ribbon
    'If you want to run a macro below when you open the workbook
    'you can call the macro like this :
End Sub

Sub GetEnabledMacro(control As IRibbonControl, ByRef Enabled)
    If MyTag = "Enable" Then
        Enabled = True
    Else
        If control.Tag Like MyTag Then
            Enabled = True
        Else
            Enabled = False
        End If
    End If
End Sub

Sub RefreshRibbon(Tag As String)
    MyTag = Tag
    If Rib Is Nothing Then
        MsgBox "Error, Save/Restart your workbook" & vbNewLine
    Else
        Rib.Invalidate
    End If
End Sub

Sub EnableAll()
    Call RefreshRibbon(Tag:="*")
End Sub

Sub DisableAll()
    Call RefreshRibbon(Tag:="")
End Sub

Sub Step1()
    Call RefreshRibbon(Tag:="*Step1*")
End Sub

Sub Step2()
    Call RefreshRibbon(Tag:="*Step2*")
End Sub

Sub Step3()
    Call RefreshRibbon(Tag:="*Step3*")
End Sub

Sub Step4()
    Call RefreshRibbon(Tag:="*Step4*")
End Sub

Sub Step5()
    Call RefreshRibbon(Tag:="*Step5*")
End Sub


Public Sub mcReturnToExcel(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!ReturnToExcel"
End Sub

Public Sub mcOpen(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!OpenFile"
End Sub

Public Sub mcClose(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!Close"
End Sub

Public Sub mcSave(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!Save"
End Sub

Public Sub mcSaveAs(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!SaveAs"
End Sub

Public Sub mcPrint(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!Print"
End Sub

Public Sub mcQuit(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!Quit"
End Sub

Public Sub mcCompany(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!Initializer"
End Sub

Public Sub mcTypes(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!WriteTypes"
End Sub

Public Sub mcClassRun(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!InvClassification"
End Sub

Public Sub mcAnalysis(control As IRibbonControl)
    Application.Run "'InvAnly.xlsm'!InvAnalysis"
End Sub
 
Upvote 0
Hard to say. Sounds complicated using an addin to display ribbon elements and then having other workbooks enabling or disabling them. What are you trying to do with that setup?
 
Upvote 0
Hard to say. Sounds complicated using an addin to display ribbon elements and then having other workbooks enabling or disabling them. What are you trying to do with that setup?

Hi,

Well, I am trying to reproduce a 2002 Excel macro file with Excel 2010.

The old excel file (on startup) create custom menu options.

After clicking the first menu option (which runs macros) the second menu option would become enabled, after clicking this the third and so on...

Also, one of the menu options would allow you to open another excel file (whilst retaining the custom menu) and continue running macros which processed the opened file by selecting the menu options.

In 2002 the menu is application-wide, in 2010 the ribbon belongs to the file itself. Thus if I kept the ribbon in my actual macro file (XLSM) - after opening the other excel file to be processed the ribbon would disappear.
So...i needed to create a ribbon in an XLAM file.

It works well when I manually open the XLAM first, then open my XLSM file, from which in turn i can open another excel file and process it using the ribbon buttons.

However I wanted to try and eliminate the step where the user has to open the XLAM file first (by putting it in the addins) - but alas this breaks the feature of enabling/disabling the ribbon buttons.

I kind of have a work around now. I have put some code in the ribbon file to load the XLSM file - much better - although it still means that the two files have to be kept together.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,927
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top