Search code examples
excelvba

Disabling the HyperlinkInsert feature of the Excel ribbon


I would like to deactivate the standard function of inserting a hyperlink using a personalized function.

The beginning of the xml code for customizing the ribbon

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="RibbonLoaded">
    <!-- Modife les commandes standard Excel Doit etre placé avant STARTFROMSCRTCH-->   
    <commands>

    <!-- Réattribue l'action du bouton "Insérer un lien hypertexte" -->
    <command idMso="HyperlinkInsert" onAction="Test" />
    <command idMso="RefreshAll" onAction="Actualisation_Tableau" />
    <command idMso="Refresh" onAction="Actualisation_Tableau" />  
    </commands>
    <ribbon>    
        <tabs>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="RibbonLoaded">
    <!-- Modife les commandes standard Excel Doit etre placé avant STARTFROMSCRTCH-->   
    <commands>

    <!-- Réattribue l'action du bouton "Insérer un lien hypertexte" -->
    <command idMso="HyperlinkInsert" onAction="Test" />
    <command idMso="RefreshAll" onAction="Actualisation_Tableau" />
    <command idMso="Refresh" onAction="Actualisation_Tableau" />  
    </commands>
    <ribbon>    
        <tabs>

The callback code in the Excel workbook

'Callback for customButton6 onAction
'Pose un lien hypertexte
Sub Test(control As IRibbonControl)
    
    POSe_HYPL

End Sub

Incorrect number of arguments or incorrect property assignment


Solution

  • The sub statement for your VBA callback should be as follows...

    Sub Test(control As IRibbonControl, ByRef cancelDefault)