• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

vba and OfficeRibbonX

Ana Luna

New Member
Dear all,
I attach an excel file that contains the Ribbon created by OfficeRibbonX with the code:
<customUI xmlns=[URL]http://schemas.microsoft.com/office/2009/07/customui[/URL]> <ribbon> <tabs> <tab id="customTab" label="Reuniones"> <group id="customGroupBuscar"> <button id="customButton1" label="Search " size="large" onAction="Macro1" getVisible=" GetButtonVisibility " /> <button id="customButton2" label="Edit" size="large" onAction="Macro2" /> </group> </tab> </tabs> </ribbon> </customUI>
This ribbon contains 2 buttoms . The customButton1 visibility depends on the value of getVisible="GetButtonVisibility", that is a Public function designed in vba like this:

>>> use code - tags <<<
Code:
Public Function GetButtonVisibility(control As IRibbonControl) As Boolean
   
    Dim currentUserName As String
    currentUserName = Application.UserName
    MsgBox currenUserName

    If currentUserName = "Iñigo Remirez de Ganuza" Then
         GetButtonVisibility = False
    Else
         GetButtonVisibility = True
    End If
  
End Function
I think it is easy but regrettably the ribbon Reuniones appears but with the next error message: wrong number of arguments or invlid property assignment.

Do you know what I have done wrong?
Regards.
Your help is much appreciated.
 

Attachments

  • book.xlsm
    12.8 KB · Views: 4
Last edited by a moderator:
Hello,

  1. The code you give for customUI14 xml is not complete and correct (unless it's a mistake on your part).
    it should be like this (don't you put the imagesMso?):
    XML:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
        <ribbon>
            <tabs>
                <tab id="customTab" label="Reuniones">
                    <group id="customGroupBuscar">
                        <button id="customButton1" label="Search " size="large" imageMso="ListMacros" onAction="Macro1" getVisible="GetButtonVisibility" />
                        <button id="customButton2" label="Edit" size="large" imageMso="AppointmentColor2" onAction="Macro2" />
                    </group>
                </tab>
            </tabs>
        </ribbon>
    </customUI>

  2. In the xlsm file, which I've set to .zip in order to unzip it, I can't see the customUI folder inside,
    nor the customUI14 xml that should be inside it.
    1695317555498.png

    When it's correct you have:
    1695329035472.png


  3. For the .rels file
    1695317632933.png
    the file is not modified, I don't see the customUI14 part :
    XML:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
    <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
    </Relationships>
    it should look like this:
    XML:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship Id="custo14" Type="http://schemas.microsoft.com/office/2007/relationships/ui/extensibility" Target="customUI/customUI14.xml"/>
    <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
    <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
    </Relationships>
  4. The code VBA in your Modulo1:
  5. Code:
    Sub GetButtonVisibility(control As IRibbonControl, ByRef returnedVal)
        returnedVal = Application.UserName <> "Iñigo Remirez de Ganuza"
    End Sub
    
    Sub Macro1(control As IRibbonControl)
        MsgBox "you ve pressed button ""Search"" OnAction "
    End Sub
    
    Sub Macro2(control As IRibbonControl)
        MsgBox "you ve pressed button ""Edit"" OnAction "
    End Sub
PS: Coucou @Marc L, if you're passing by, regarding customUI ribbon customization, "almost" everyone said you could only do it on PC, I've just proved the opposite by doing it manually on Mac :cool: ;)
 

Attachments

  • Book2.xlsm
    14.3 KB · Views: 4
Hi Ryu !​
I never had to play with the ribbon, as I prefer the previous system until 2003 version which still used under upper versions.​
I did not know the ribbon customization was 'only' under Windows, anyway well done under a Mac !​
 
Hello,

  1. The code you give for customUI14 xml is not complete and correct (unless it's a mistake on your part).
    it should be like this (don't you put the imagesMso?):
    XML:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
        <ribbon>
            <tabs>
                <tab id="customTab" label="Reuniones">
                    <group id="customGroupBuscar">
                        <button id="customButton1" label="Search " size="large" imageMso="ListMacros" onAction="Macro1" getVisible="GetButtonVisibility" />
                        <button id="customButton2" label="Edit" size="large" imageMso="AppointmentColor2" onAction="Macro2" />
                    </group>
                </tab>
            </tabs>
        </ribbon>
    </customUI>

  2. In the xlsm file, which I've set to .zip in order to unzip it, I can't see the customUI folder inside,
    nor the customUI14 xml that should be inside it.
    View attachment 85259

    When it's correct you have:
    View attachment 85263


  3. For the .rels file
    View attachment 85260
    the file is not modified, I don't see the customUI14 part :
    XML:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
    <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
    </Relationships>
    it should look like this:
    XML:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship Id="custo14" Type="http://schemas.microsoft.com/office/2007/relationships/ui/extensibility" Target="customUI/customUI14.xml"/>
    <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
    <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
    </Relationships>
  4. The code VBA in your Modulo1:
  5. Code:
    Sub GetButtonVisibility(control As IRibbonControl, ByRef returnedVal)
        returnedVal = Application.UserName <> "Iñigo Remirez de Ganuza"
    End Sub
    
    Sub Macro1(control As IRibbonControl)
        MsgBox "you ve pressed button ""Search"" OnAction "
    End Sub
    
    Sub Macro2(control As IRibbonControl)
        MsgBox "you ve pressed button ""Edit"" OnAction "
    End Sub
PS: Coucou @Marc L, if you're passing by, regarding customUI ribbon customization, "almost" everyone said you could only do it on PC, I've just proved the opposite by doing it manually on Mac :cool: ;)
Dear Ryuautodidacte, I have followed your instructions and now my filter with RibbonX works perfectly!, thank you so much. You've saved me a lot of time. Thank you.
 
Back
Top