+ Reply to Thread
Results 1 to 19 of 19

ActiveX Buttons in Ribbon

  1. #1
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Question ActiveX Buttons in Ribbon

    Hi All, I'm creating a custom tab in the ribbon where I have assigned the applicable buttons that I currently have assigned to the workbook.

    The buttons are ActiveX and have been coded that way, How do I assign the correct code to the buttons in the ribbon?

    I managed to get half of them to work (mainly the ones that just call 'UserForm.show' for example), but with others that have various references to tables and scripts and the code for some is fairly complicated, it just does not work.

    How do I go about this? not sure what info you will need so please ask and will provide you with such.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: ActiveX Buttons in Ribbon

    You can't put activex buttons in the ribbon, if that's what you are saying.

    Ribbon buttons use callbacks, but for existing macros you can just add them to the ribbon and everything is done for you, so I'm not really sure where you are stuck?
    Rory

  3. #3
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100
    Quote Originally Posted by rorya View Post
    You can't put activex buttons in the ribbon, if that's what you are saying.

    Ribbon buttons use callbacks, but for existing macros you can just add them to the ribbon and everything is done for you, so I'm not really sure where you are stuck?
    Okay, well I’m not sure why there’s a ribbon button for activex? That’s very confusing… however what I did do that made some work was literally copy paste the code from the sheet into a module. I do know that this is the wrong way of doing it.

    But now if what you say is true, how do I turn my activex buttons to normal command buttons?

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: ActiveX Buttons in Ribbon

    There is a section on the ribbon for adding activex controls to a worksheet; that is not the same as ribbon buttons being activex.

    If you want to call the code from a ribbon button, it does belong in a normal module, not a worksheet module. I'm not sure why you think that's wrong?

  5. #5
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: ActiveX Buttons in Ribbon

    Just to clarify, as per the attached pictures, the ActiveX command button is not an ActiveX button? That's very confusing!

    What I was saying is copy pasting the full code applied to the buttons into a module.

    What are my other options here since i cannot assign my current ActiveX controls into the ribbon?
    Attached Images Attached Images

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: ActiveX Buttons in Ribbon

    That is the menu button to create an activex button. It is not itself an activex button, any more than the button to create a combobox is a combobox.

    And yes, moving the code to a normal module is what you need to do. I was asking why you think that is wrong?

  7. #7
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: ActiveX Buttons in Ribbon

    My issue is that I am unable to use the code in a module:

    Code as follows:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by MyForcey; 11-16-2021 at 08:17 AM.

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: ActiveX Buttons in Ribbon

    What does "unable" actually mean? There doesn't appear to be anything in that code that would require it to be in a worksheet code module.

  9. #9
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: ActiveX Buttons in Ribbon

    There is another bit of code which updates by CLS_Record which i am not allowed to post here.

  10. #10
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: ActiveX Buttons in Ribbon

    Errors such as "Private WithEvents FormRecEntry As UserForm1" not allowed.

    Using "with me." says its invalid.

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: ActiveX Buttons in Ribbon

    You have to replace Me with a reference to the relevant sheet/object. WithEvents variables do need to be in a class, so you will either need to create one, or put them in an existing one and adjust any calling code as necessary.

  12. #12
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: ActiveX Buttons in Ribbon

    and how do I do that?
    so for eg. I would replace all "Me." with "Sheet1."?
    Then place all the variables listed at the top into a new module?

    Then after ActiveX buttons will work in the ribbon?

  13. #13
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: ActiveX Buttons in Ribbon

    If Me was referring to Sheet1, then yes.

    As I said, any WithEvents variables need to be in a class module. The other variables can be in a regular module.

    No, you can't put activex buttons in the ribbon, but you don't need to so that's irrelevant.

  14. #14
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: ActiveX Buttons in Ribbon

    I'm getting an "error424Object"

  15. #15
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: ActiveX Buttons in Ribbon

    Then whatever change you made was wrong.

  16. #16
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: ActiveX Buttons in Ribbon

    If I didn't know that already I would have told you it doesn't work instead of listing the actual error.

  17. #17
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: ActiveX Buttons in Ribbon

    That may be true but you didn't say what you changed (from / to) that caused the error...

  18. #18
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: ActiveX Buttons in Ribbon

    Thank you for the negative rep. I wish you luck with your project.

  19. #19
    Forum Contributor
    Join Date
    08-02-2021
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    100

    Re: ActiveX Buttons in Ribbon

    Many thanks man, I got it done.. All that I did was change private to public and kept the code where it was. works perfectly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. how to disable buttons on a custom ribbon
    By diego208 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2020, 11:00 AM
  2. Customized Buttons in Ribbon Bar
    By BrianAll in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2018, 04:24 AM
  3. custom ribbon buttons by VBA
    By muss1210 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2018, 09:27 AM
  4. Excel Ribbon Buttons
    By ry94080 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2017, 04:28 PM
  5. Creation of Ribbon and buttons from Add-in
    By Rudey3991 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2016, 07:00 AM
  6. Mix up of buttons in Excel Add-In ribbon - how to delete buttons?
    By lausianne in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-11-2013, 08:51 AM
  7. How to add buttons to a ribbon - EXCEL 2007
    By avveerkar in forum Excel General
    Replies: 7
    Last Post: 02-16-2011, 03:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1