Adding macro button to trigger a specific Macro - ms-office

Whenever I add a custom Macro button to the Quick Access Toolbar , it is a generic Macro window invocation button. What I want is that if I click on the button, a specific Macro should directly start running. As of now there are 2-3 steps before I do that. First of all I click on the icon on the quick access toolbar , another small drop down shows up unnecessarily as shown here ( not sure why Add Ons is appearing here, I never added)
Secondly, if I click on the bigger Macros icon in the dropdown again , I get a dialog box where I have to choose macro from a list. I don't want to go through all this. As soon as I click on the button, a specific macro (I should be able to configure name of the macro) should start. I know there is a shortcut available for triggering a specific macro but I prefer a button.

If you don't want to configure QAT buttons manually you may consider developing a COM based add-in instead. See Walkthrough: Create your first VSTO Add-in for Outlook for more information.
To customize the ribbon UI you can use the designer provided by VSTO, see Walkthrough: Create a custom tab by using the Ribbon Designer.

Related

VBA - iRibboncontrol & different Sub not working

I have a macro-enabled excel workbook that has a custom menu with different buttons that work beautifully - used Custom-UI editor for this.
When I try to create a new Macro that runs and starts a custom menu with custom menu items, it does not want to work.
If I create a new macro-enabled workbook without a custom menu (iRibboncontrol items), then the menu code works.
Is there a way to have both the iRibboncontrol Custom Ribbon AND a custom menu? If so, please can someone assist?
Update
Figured out that Page Break Preview is the reason why my custom right-click menu breaks.
Any suggestions on how to get it working?

Change macro location of a custom button in ribbon

It is possible to change the "location" of the macro that runs when clicking on a custom button that was added to the ribbon?
Let me explain the situation:
I'm starting from a template (let's say template.xltm, so my temporary file is template01) , which contains that ribbon code.
I save that template-sheet into the file I want, let's say file1.xlsm.
Now I want to click that button again in the ribbon, the code should be run from the file1.xlsm macro (that has the same function name) and not from that template file (template.xltm).
Adding the macro to the ribbon should be enough as the macro will run on the file it was activated from rather then the file it is stored in.
I have a whole bunch of different macros that I use regularly and needed quick and simple way to access it so I designated a workbook for my macros and created a custom tab with buttons for all macros I need.

Trying to ID a CommandButton on an Excel 2010 VBA application

I've just started a new contract and am working with Office VBA again after about 20 years. There is a spreadsheet I'm working on where command buttons disappear after the document saves. I've been reading other threads that suggest as a fix setting the size of the button after saving. However, I can't figure out how to identify that button in code.
When I click "Format", there is no place where the name of the object appears. There's a macro attached to it, but I see no way to identify the "sender" when the macro fires.
The macro pops up a form, and after the user enters some information and submits, it saves the sheet, and the button goes "poof".
Is there any way to get the name of the button in the macro so I can resize it?
Thanks!
If you right-click the button, its name appears in the upper left hand corner of the spreadsheet in the Developer ribbon, right below the "Visual Basic" and "Macros" menu items. In my case, it was "Button 1".
Accessing it was non-intuitive for a guy used to working with full-blown .NET apps, but the button is a "Shape". So, addressing the button is accomplished with the identifier ActiveSheet.Shapes("Button 1"). With this object, you can access its properties and methods.

Add a new button under "Home" Tab in excel

I am trying to add a new button under Fill color in Home tab in excel
I have tried adding my button by going to File > Option > Customize Ribbon but the options are disabled
I want to add my button in "Home" tab
Here is an interesting way of customizing the ribbon in excel (still works in Excel 2016) :
https://www.rondebruin.nl/win/s2/win001.htm
In brief, with the help of CustomUI you will modify part of the file archive in the way that you can remove actual tabs, add your own tab, and custom buttons inside of it
You asked for adding a button in the "Home" tab, a workaround would be recreating "Home" tab in a personnal ribbon tab and adding your own button to it. Your personnal button could trigger a macro sub (VBA) or even use native Excel functionalities.
(I can help you further if you choose this way)

Is it possible to click buttons in the toolbar with macros in Excel 2010?

Is there anyway to make a macro that can click buttons in the tool bars of Excel? I'm using Excel 2010.
Here's how you can record a macro, which will capture your actions.
For Excel 2010:
http://www.dummies.com/how-to/content/how-to-record-a-macro-to-automate-tasks-in-excel-2.html
For Excel 2013:
http://www.dummies.com/how-to/content/how-to-record-new-macros-in-excel-2013.html
In your case, to take this even further, you can do coded UI testing right from Visual Studio. For what you are trying to do, this is even better than only trying to automate a button-click to fire a custom add-in.
Here is a way how you can achieve it with excel 2010:
File->Options->Quick Access Toolbar.
in the "Choose Commands From" list you click "Macros". Select the macro and click add.
If you want change the name of the button you can click "Modify".
Hope it will help you.

Resources