Excel Ribbon Macro not enabled

0 votes

Numerous Excel spreadsheets feature unique ribbons. Excel occasionally provides an error message stating that the '_getEnabled' macro is disabled (see image). Every ribbon control that uses a macro to manage the enabled attribute displays this message.

macro is disabled error message

The XML in the ribbon is (some names are redacted):

<button id="name_btn" size="large" image="imagename" label="somelabel" getEnabled="VBA_####.######_getEnabled" onAction="VBA_####.######_onAction"/>

The VBA is:

Sub ######_getEnabled(control As IRibbonControl, ByRef returnedVal)
    returnedVal = CheckPermissions("SomeName")
End Sub

Has anyone else noticed this mistake? While Excel appears to be attempting to update the ribbon controls for the workbook that contains the code, error messages appear when another workbook is the active workbook. As was previously mentioned, this occurs occasionally, and there is no discernible pattern.

Nov 11, 2022 in Others by Kithuzzz
• 38,010 points

1 answer to this question.

0 votes

If you place a breakpoint in one of the VBA callbacks (GetImage, GelLabel, GetEnabled, etc.) then activate a different workbook when the code breaks, you can duplicate the behavior. Finally, the error will appear when you execute the code again (for example, by pressing F5).

Using the ribbon. Invalidate method, you may make the ribbon refresh automatically (if you previously saved the ribbon object). The ribbon object can be saved by specifying a onLoad callback:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="InitRibbon">

with this in VBA:

Private moduleLevelRibbonObject As IRibbonUI

Public Sub InitRibbon(ribbon As IRibbonUI)
    Set moduleLevelRibbonObject = ribbon
End Sub

Calling moduleLevelRibbonObject.Invalidate will refresh the ribbon (if the state was not lost - but that is a different topic).

A quick fix that I've found. Just add something like this:

If Not ThisWorkbook Is ActiveWorkbook Then ThisWorkbook.Activate

I hope this helps you.

answered Nov 11, 2022 by narikkadan
• 63,160 points

Related Questions In Others

0 votes
1 answer

Nokia Lumia 920 Excel not open

The issue is with your code, not ...READ MORE

answered Sep 27, 2022 in Others by narikkadan
• 63,160 points
0 votes
1 answer
0 votes
1 answer

Moving Average formula in Excel not autofilling in table

You could use AVERAGEIFS to make the ...READ MORE

answered Oct 2, 2022 in Others by narikkadan
• 63,160 points
0 votes
1 answer

Lock down Microsoft Excel macro

Protect/Lock Excel VBA Code: When we write VBA ...READ MORE

answered Oct 3, 2022 in Others by narikkadan
• 63,160 points
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,220 points
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,670 points
0 votes
1 answer

Excel VBA is not recording macro properly

The "awkward code" is an R1C1 notation ...READ MORE

answered Nov 15, 2022 in Others by narikkadan
• 63,160 points
0 votes
1 answer

JavaScript API does not work for Excel 2013?

Each method in the Office.js APIs is ...READ MORE

answered Sep 26, 2022 in Others by narikkadan
• 63,160 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP