VBA - iRibboncontrol & different Sub not working - excel

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?

Related

Adding macro button to trigger a specific Macro

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.

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.

Custom Menu visible to one document in Excel

I have created customized menu and toolbar in MS Excel. I wanted to show this menu and toolbar to specific document only. When I open any other xls file, it shows that menu and toolbar.
MS Excel 2003
How to do that using vba-excel macro or any other way to do that?
If you need more information, please ask me.
Thanks :)
OK - so this website will help you:
http://www.ozgrid.com/VBA/custom-menus.htm
It actually works in Excel 2007 also, but adds the menu under the Add-Ins tab.
You basically need to access the code for ThisWorkbook in the VBA application. From there, you can modify the Application.CommandBars object to do what you need.

How do I remove a custom toolbar from an Excel workbook?

I'm using Excel 2007, and I have an Excel workbook with a custom toolbar attached. Every time I open the workbook, the toolbar appears on the ribbon under "Add-ins". I can right-click on the toolbar and choose Delete Custom Toolbar and that removes it. But when I re-open the workbook, it re-appears. How do I remove it for good?
The toolbar is not created by VBA. It was attached to the workbook in an earlier version of Excel using the steps outlined in http://office.microsoft.com/en-us/excel/HP051986401033.aspx.
I realize this is an old question, but I just found an easy solution not mentioned on here that will be of use to future viewers:
Change the file's extension to ".zip"
Open the archive
Delete the Attachedtoolbars.bin file from the archive
Close the archive
Change the file's extension back to what it was originally
While the proper solution is detaching the toolbar from the workbook, I'm not sure how that is done in Excel 2007. As a workaround, a macro can be used to delete the toolbar every time the workbook is opened:
Private Sub Workbook_Open()
' Delete the unwanted toolbar that is attached to this workbook.
Dim cmdbar As CommandBar
For Each cmdbar In Application.CommandBars
If cmdbar.Name = "Zap" Then
cmdbar.Delete
End If
Next End Sub
End Sub
I found two ways wich worked for me:
Open in Office 2003 and detach the custom toolbar: Tools > Customize > Tab Toolbars > Button Attach... > Delete custom toolbar in workbook
Open in Office 2007 and export all Objects, Forms, Modules and Class Modules and import them into a new fresh workbook (.xlsm)
You will get rid of all old garbage and all macro's still work.
If it is not VBA you could go into the registry to disable the Addin associated with the toolbar.
You can also loop through all the Commandbars in Excel.Application.CommandBars and find toolbar by its name, and delete it then. This is assuming the toolbar is stuck there from a previous session (and that the workbook/addin/etc that added the toolbar didn't remove it in the Workbook_Beforeclose event)
Or, if it is not done in VBA, you could just simply:
Right click in the menu bar region, click customize
In the Toolbar tab click on attach and make sure it is not attached to the workbook.
Sometimes people forget the basics...
I had the same problem with a spreadsheet which displayed a custom toolbar, then left it in my default toolbar file.
I found this solution:
http://support.microsoft.com/kb/291074
In Excel 2007, the file to delete is
c:\Winnt\profiles\username\Application Data\Microsoft\Excel\Excel12.xlb
Worked perfectly for me (though it deletes all custom toolbars you might have installed).
I know this question is old, but what finally worked for me is going into the bin/debug folder of my excel addin project and deleting all the files, then reloading Excel.
See the answer here:
http://msdn.microsoft.com/en-us/library/office/ff862231%28v=office.15%29.aspx
For Each bar In CommandBars
If bar.BuiltIn = False Then
bar.Delete
End If
Next bar
In all likelihood, there is VBA code attached to the workbook with an onLoad event that creates the toolbar.
You'll have to go delete or disable the VBA code.
We have the same problem with the ribbon in our production 2010 Excel spreadsheets that need changes. The custom ribbon needs to be modified but it is locked at every location from we have tried to edit/remove it.
Right-clicking on the toolbar does not work since the "Customize..." selections are disabled.
Removing all the VBA code has no effect, the custom ribbon still replaces the default ribbon.
In Excel Options, the "Customize the Ribbon" controls contain no selections or are disabled.
In the VBA window under View, Toolbars, Customize, the Menu Bar toolbar is locked for editing.
We have tried to locate files on the hard disk as suggested by a few posts, but the files are not found (even the folder hierarchy does not exist).
Options off the table are editing the registry or creating entirely new files by importing objects.
Question: Why do they make it so difficult to manage the ribbon?

Resources