+ Reply to Thread
Results 1 to 6 of 6

Converting VBA User Form Program to Run from a Ribbon Button?

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2016
    Posts
    38

    Converting VBA User Form Program to Run from a Ribbon Button?

    I have created a VBA program that performs some calculations on the current worksheet. The User Form has several text fields, check boxes, combo boxes and buttons that require the user's input to direct the program on what columns/calculations need to be performed.

    What I would like to do now, is figure out a way to have a new button added to the top Add-Ins ribbon such that when it's pressed, the User Form opens for the user to enter the data, and when the "Calculate" button I have is pressed, it performs the actions on the current worksheet. ChatGPT just sucks too much to figure it out for me after a few hours of trying so I figured I'd come here to the pros!

    The file is currently in .XLSM format, and the code only has 1 user form with all of the code for it in it (I'll refrain from posting the entire code just yet as I don't think it's relevant to my question anyway, but if the code is needed just say so). I'd like the user form to appear when I press a newly made ribbon button from ANY excel file that I open.

    I am running Excel 365 from Windows 10. If someone can try to do something similar on their end and detail step by step what needs to happen and let me know? This is my first time trying to make a custom Add-In. Some things I've tried so far, but to no avail (unless I wasn't doing the steps correctly) were:

    1. Save a copy of the .XLSM file as a .XLAM file in the Excel Add-Ins folder
    2. Change the .XLAM file extension to a .ZIP file, add a new "customUI" folder inside, and add in a .RELS file with some code in it
    3. Close the .ZIP file and change it back to a .XLAM
    4. Enable the add-in through the options menu and it should just "appear" in the ribbon somewhere (it didn't).

    Other similar attempts were tried, including adding an OnWorkbookOpen event listener to the code, making a reference to the RibbonsCallback (which was a nightmare in and of itself as the Microsoft Office XX.XX Objects Library isn't even in the References table anywhere), etc. So I need some detailed steps to figure this out.

    Thanks!

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Converting VBA User Form Program to Run from a Ribbon Button?

    Is it what you want ..?
    See attached a file with a personal menu "Saint Hubert"
    There is 3 buttons assigned to a macro:
    Sub Group1_Bt(1 to 3)(ByVal control As IRibbonControl)
    You may reuse these macro for your personal need or change them with your's
    Then if you want to change the menu name or icon it can be done
    Good luck
    Attached Files Attached Files
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    07-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2016
    Posts
    38

    Re: Converting VBA User Form Program to Run from a Ribbon Button?

    @PCI This is exactly what I'm looking for, thank you! However, is it possible to make those buttons in the ribbon work across all Excel files instead of just being hosted in the one? I'd like to be able to have it implanted into Excel so that no matter what file I open, I can launch my user form and run it on whatever book's sheet I currently have loaded?

  4. #4
    Forum Contributor
    Join Date
    02-25-2022
    Location
    Dallas, Texas
    MS-Off Ver
    Office 365
    Posts
    174

    Re: Converting VBA User Form Program to Run from a Ribbon Button?

    The way I do it is to create an Excel addin (.xlam). You can put the custom UI in the addin. I have a form that allows me select a workbook to work on. I put all the code in the addin. I use the Custom UI Editor for Microsoft Office to customize ribbon and QAT. Bing/Youtube Custom UI Editor for Microsoft Office.

  5. #5
    Registered User
    Join Date
    07-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2016
    Posts
    38

    Re: Converting VBA User Form Program to Run from a Ribbon Button?

    Thanks @mogul, with your suggestion, I found this page:

    https://bettersolutions.com/vba/ribb...mui-editor.htm

    This looks like it should do what I'm after, but will attempt it on my end and let everyone know the results.

  6. #6
    Registered User
    Join Date
    07-24-2013
    Location
    Canada
    MS-Off Ver
    Excel 2016
    Posts
    38

    Re: Converting VBA User Form Program to Run from a Ribbon Button?

    Thanks to those who answered! I was able to get it working by following the steps on that link. Specifically for my use case, I did:

    1. Created my User Form/program in .XLSM format
    2. File > Info > Properties drop-down (on the right) > Advanced Properties
    3. Added a title and comments
    4. Opened Visual Basic Editor (ALT + F11), and added the following code to the ThisWorkbook object:

    Please Login or Register  to view this content.
    5. Saved the workbook (CTRL + S), then File > Save As, and saved it as .XLAM file (Excel Add-In format)
    6. Downloaded the RibbonX Editor installed from here and installed/ran the application:
    https://github.com/fernandreu/office...-Installer.exe
    7. File > Opened the new .XLAM file, right+clicked the new filename on the left window pane of the RibbonX Editor GUI, and selected Office 2010+ Custom UI Part
    8. After double-clicking the file again, inserted this code into the window on the right:

    Please Login or Register  to view this content.
    9. Validated the code from the Validate button, and File > Save All.
    10. Shut down the RibbonX Editor and closed out of Excel.
    11. Opened a new blank Excel file/instance, enabled the add-in (File > Options > Add-Ins > Excel Add-ins > Go > Check the my Weighted Scoring add-in's checkbox)
    12. Profit! New tab group across the top ribbon shows with my new add-in!

    Thanks again, hope this helps others.

+ 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. [SOLVED] User Form automatically sends SMS Text Msg when user presses Submit Button
    By BigHungarian in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-19-2021, 12:28 PM
  2. Creating a User Form to cover up the Ribbon and Title Bar
    By superlative in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2019, 04:28 PM
  3. [SOLVED] Code to program a command button on a user form to advance to the next page...?
    By LuScannon in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-01-2017, 12:32 PM
  4. [SOLVED] User Form - Hyperlink Button within a Form, to create a Link on a Designated Cell
    By Sinalk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2013, 07:29 AM
  5. [SOLVED] How do I program in VBA, the background color of a Form Control Button?
    By redsab in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2013, 10:27 PM
  6. [SOLVED] Excel 2007: Ribbon set to hide, but doesn't before User Form opens.
    By Casedias in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-16-2011, 02:27 AM
  7. How do I program a 'click' for a button on a form
    By johncassell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-07-2009, 08:54 AM

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