SOLVED

Custimising Ribbon

%3CLINGO-SUB%20id%3D%22lingo-sub-2285756%22%20slang%3D%22en-US%22%3ECustimising%20Ribbon%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2285756%22%20slang%3D%22en-US%22%3E%3CP%3EMy%20machine%20uses%20Windows%2010%20and%20Excel%202019.%20I%20am%20aiming%20to%20add%20a%20dozen%20or%20so%20custom%20buttons%20to%20the%20Ribbon%20to%20invoke%20some%20macros%20that%20have%20been%20tried%20and%20tested%20on%20Excel%202000.%3C%2FP%3E%3CP%3EAs%20simple%20trial%20of%20the%20proposed%20system%2C%20I%20have%20written%20some%20XML%20to%20add%20%26nbsp%3B%20a%20custom%20tab%20to%20the%20ribbon%20with%20one%20group%20containing%20one%20button%20with%20a%20custom%20icon%3C%2FP%3E%3CP%3E%3CCUSTOMUI%20xmlns%3D%22%26quot%3B%26lt%3BA%22%20href%3D%22http%3A%2F%2Fschemas.microsoft.com%2Foffice%2F2006%2F01%2Fcustomui%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CA%20href%3D%22http%3A%2F%2Fschemas.microsoft.com%2Foffice%2F2006%2F01%2Fcustomui%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttp%3A%2F%2Fschemas.microsoft.com%2Foffice%2F2006%2F01%2Fcustomui%3C%2FA%3E%22%26gt%3B%3C%2FCUSTOMUI%3E%3C%2FP%3E%3CP%3E%3CRIBBON%3E%3C%2FRIBBON%3E%3C%2FP%3E%3CP%3E%3CTABS%3E%3C%2FTABS%3E%3C%2FP%3E%3CP%3E%3CTAB%20id%3D%22%26quot%3Bfirst_tab%26quot%3B%22%20label%3D%22%26quot%3BOur%22%20first%3D%22%22%20tab%3D%22%22%3E%3C%2FTAB%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CGROUP%20id%3D%22%26quot%3Bgroup1%26quot%3B%22%20label%3D%22%26quot%3BFirst%22%20group%3D%22%22%3E%3C%2FGROUP%3E%3C%2FP%3E%3CP%3E%3CBUTTON%20id%3D%22%26quot%3Bbutton1%26quot%3B%22%20label%3D%22%26quot%3BHello%22%20world%3D%22%22%3E%3C%2FBUTTON%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThere%20are%20various%20%3CSTRONG%3E.%3C%2FSTRONG%3Erels%20files%20of%20course.%3C%2FP%3E%3CP%3EI%20have%20written%20two%20simple%20macros%2C%20stored%20in%20Module1%20of%20the%20Personal.xlsb%3C%2FP%3E%3CP%3ESub%20HelloWorld_1()%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%20MsgBox%20%22Hello%20World%20One%22%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3CP%3ESub%20HelloWorld_2(control1234%20As%20IRibbonControl)%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%20MsgBox%20%22Hello%20World%20Two%22%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3CP%3EThe%20Project%20Explorer%20shows%20that%20they%20are%20available%20to%20my%20Workbook.%20All%20looks%20OK%2C%20with%20the%20tab%2C%20group%2C%20button%2C%20and%20icon%20showing%2C%20but%20the%20callback%20does%20not%20work.%3C%2FP%3E%3CP%3EMacro%201%20works%20well%20when%20invoked%20using%20Developer%20-%26gt%3B%20Macros%20-%26gt%3B%20Run.%3C%2FP%3E%3CP%3EHowever%2C%20clicking%20button1%20gives%20the%20message%3A%3CBR%20%2F%3E%E2%80%9CCannot%20run%20the%20macro%20'HelloWorld_2.%20The%20macro%20may%20not%20be%20available%20in%20this%20workbook%20or%20all%20macros%20may%20be%20disabled.%E2%80%9D%3C%2FP%3E%3CP%3ECan%20anybody%20help%20please.%3F%3C%2FP%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2285756%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2286782%22%20slang%3D%22en-US%22%3ERe%3A%20Custimising%20Ribbon%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2286782%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570065%22%20target%3D%22_blank%22%3E%40GregoryGoon%3C%2FA%3E%26nbsp%3B%2C%20Hi%2C%20i%20think%20you%20need%20to%20write%20full%20address%20of%20the%20macro%20in%20the%20xml.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESomething%20like%20%3A-%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EonAction%3D%22'C%3A%5C....path%20of%20personal.xlsb.....%5C%3CSPAN%3EPersonal.xlsb%3C%2FSPAN%3E'!%3CSPAN%3EHelloWorld_2%3C%2FSPAN%3E%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMost%20possibly%2C%20the%20complete%20path%20is%20as%20below%20%3A-%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EonAction%3D%22'C%3A%5CUsers%5C%3C%2FSPAN%3E%3CSTRONG%3E%22user%20name%22%3C%2FSTRONG%3E%3CSPAN%3E%5CAppData%5CRoaming%5CMicrosoft%5CExcel%5CXLStart%5CPersonal.xlsb'!HelloWorld_2%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Ewhere%20user%20name%20is%20your%20windows%20account%20name%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Regular Visitor

My machine uses Windows 10 and Excel 2019. I am aiming to add a dozen or so custom buttons to the Ribbon to invoke some macros that have been tried and tested on Excel 2000.

As simple trial of the proposed system, I have written some XML to add   a custom tab to the ribbon with one group containing one button with a custom icon

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

<ribbon>

<tabs>

<tab id = "first_tab" label = "Our First Tab">

     <group id = "group1" label = "First Group">

<button id = "button1" label = "Hello World" image = "RedButton9731" size="large" onAction = "HelloWorld_2"/>

     </group>

</tab>

</tabs>

</ribbon>

</customUI>

There are various .rels files of course.

I have written two simple macros, stored in Module1 of the Personal.xlsb

Sub HelloWorld_1()

   MsgBox "Hello World One"

End Sub

Sub HelloWorld_2(control1234 As IRibbonControl)

   MsgBox "Hello World Two"

End Sub

The Project Explorer shows that they are available to my Workbook. All looks OK, with the tab, group, button, and icon showing, but the callback does not work.

Macro 1 works well when invoked using Developer -> Macros -> Run.

However, clicking button1 gives the message:
“Cannot run the macro 'HelloWorld_2. The macro may not be available in this workbook or all macros may be disabled.”

Can anybody help please.?

1 Reply
best response confirmed by GregoryGoon (Regular Visitor)
Solution

@GregoryGoon , Hi, i think you need to write full address of the macro in the xml.

 

Something like :-

 

onAction="'C:\....path of personal.xlsb.....\Personal.xlsb'!HelloWorld_2"

 

Most possibly, the complete path is as below :-

 

onAction="'C:\Users\"user name"\AppData\Roaming\Microsoft\Excel\XLStart\Personal.xlsb'!HelloWorld_2"

 

where user name is your windows account name