Using an .xlam project with a fully working custom ribbon, I have found that the new tab will sometimes show nothing when clicked on. It is intermittent. The global RibbonUI object is available and running an .invalidate will then show the ribbon. However, the .invlalidate attempts prior to the tab being viewed do not seem to change this behavior. I have to view the tab and then run the .invalidate manually (with a macro button) to see the ribbon appear.
I am scratching my head trying to find a slick way of making this new custom tab populate 100% of the time.
For the benefit of those that come across this issue, I have found the root cause and a solution. This is Excel O365 specific.
If you have a custom ribbon tab set up and working, try this. Open Excel, create a blank workbook, then double-click on a cell to put it in "edit mode". Click on your custom ribbon tab. Blank, right?
This "cell in edit mode" is what was causing Excel O365 to fail to show my custom ribbon. Excel O365 starts up on the "File" screen. Prior versions always opened to a blank sheet. If you click on "Blank workbook", the ribbon displays fine. If you DOUBLE-CLICK on "Blank workbook", the first click opens the workbook and the second click puts a cell into ""edit mode". In this state, clicking on your custom ribbon tab shows nothing.
The work-around
Private Sub WorkbookActivate(ByVal Wb As Workbook)
Application.SendKeys "{ESC}"
...
You may see a cell go into edit mode for one blink but it then exits edit mode. Click on your custom ribbon tab. It will now show the ribbon controls as designed.
Related
I have a macro-enabled Excel template which contains a ribbon button pointing to a macro sub. The button assignment still points to the source template, however, instead of the sub in the new document. If I create a document and then move or delete the template, I'm no longer able to use the button in the new document:
I've noticed that the ribbon button seems have the macro's source template path hard-coded, and there isn't any place I can find in ribbon customization UI to change it:
I'm certain this has been asked before, but I've tried a number of different ways of searching for it without coming up with anything.
I found this which talks about a button on a form, not a ribbon, and I found this which seems to be generating "shapes" programmatically and assigning their action; neither of these two are relevant.
This is the closest I've found, but whereas the QAT customization tab has the option for setting the target:
the ribbon customization tab does not have that. Any help would be greatly appreciated.
The program, that I'm working on, has a separate (additional) Add-in tab in the Excel ribbon. And there are our custom controls, etc. Some of the controls open a new workbook (new Excel window).
In Excel 2010, when the new workbook is opened, our custom tab is selected by default. But in 2013, the first (Home) tab is selected.
In the project, there is no code that controls which tab to be selected by default in a newly open workbook. That is why I am wondering it works in 2010, but not in 2013?
I researched about that, but I could find mostly articles about "how to create new tab", etc.
Any ideas and suggestions are welcome.
This should be the fix you're looking for:
yourRibbonInstance.ActivateTab("tabID")
keep in mind that the id of the tab might not be the same as its displayed name.
Not sure if this might be overkill but you could use a macro that runs on the workbook open event to activate the sheet you want to see first..
Sub workbook_open()
Sheets("Sheet2").Activate
End Sub
I have a customized ribbon where I added a tab containing a toggle button. This toggle button has a getPressed attribute which is linked to a callback function returning the pressed state of the toggle button. The purpose of the toggle button is to display/hide a custom task pane. This works fine.
However, my issue is that in Excel 2013, if I have two or more workbooks open, when I invalidate the toggle button, only the one of the active workbook is updated. I also want to update the pressed state of the toggle buttons on the other workbooks as the custom task pane is either visible or invisible in all workbooks.
Anyone knows how to do invalidate a control in the ribbon of all workbooks in Excel 2013?
I am using vb.net and excel-dna.
The toggle button is defined like that:
<toggleButton id="toggleButtonInputData" size="large" onAction="rxToggleButton_onAction" getPressed="rxToggleButton_getPressed" getImage="rxButton_GetImage" getLabel="rxbutton_GetLabel" getEnabled="rxGenericControl_GetEnabled" visible="true"/>
The callback function is:
Function rxToggleButton_GetPressed(ctl As CustomUI.IRibbonControl) As Object
Select Case ctl.Id
Case "toggleButtonInputData"
Return CTP_InputData.IsToggleButtonPressed
End Select
End Function
To invalidate the toggle button I use :
Public Sub CTP_InputData_VisibleStateChange() Handles CTP_InputData.VisibleStateChange
XLRibbon.myRibbon.InvalidateControl("toggleButtonInputData")
End Sub
The Invalidation is only processed for the active workbook's ribbon. But when you then switch to another workbook, the callbacks will fire again and will now be applied to the ribbon of the new workbook.
There's a bug and some quirks in Excel 2013 related to this switching:
If you click on the title bar or the ribbon of the workbook you want to activate, everything works as expected. But if you click on a cell in the workbook you're activating, you get two callbacks - the first is applied to the deactivating workbook's ribbon, and the second is applied to the activating workbook's ribbon. The problem is that you cannot distinguish (in your callback) whether you are getting called for the deactivating book. (Using COM events doesn't help either, both callbacks happen after all the COM Workbook- and Window- (De)Activate events have fired.
Apart from this quirky behaviour, one clear bug in Excel 2013 is that the IRibbonControl.Context is not set to the correct window - in both of the callbacks it reflects the activating window, though the first callback will be applied to the deactivating window.
Here's a detailed discussion on the issue: https://social.msdn.microsoft.com/Forums/windowsserver/en-US/a3dade87-1df7-46ec-8876-437194d7553e/how-to-reference-the-correct-workbook-from-a-control-in-a-ribbon-callback?forum=exceldev
In summary, you don't have good control over the state of deactivated ribbons. But if you are only worried about the active ribbon, Invalidate works fine, but you must expect the callback only upon activation.
Within Powerpoint 2010 I have customised a tab on ribbon with both standard and custom macro buttons using 'customize the ribbon'.
In an attempt to share this ribbon with friends I have exported the ribbon as an .exportedUI file and saved the presentation as a macro enabled template.
When I open up any file called (Presentation1) the buttons work fine as the name for the macros are 'Presentation1'!macro#. If I then save as or open another blank (Presentation 2) the buttons produce the error:
"The macro could not be found or has been disabled because of your security settings"
The problem appears to be with the name of the macro that is associated with the button.
Is it possible to mix custom with standard buttons on an exportable ribbon? Or will I have to create an add-in that produces a new tab then replicate the standard buttons required? I know it is possible to do this in Excel and in Word but in Powerpoint it appears not to be?
How do I:
add button to my ms word 2007 document (i would say this would be trivial task, but can't even figure THIS out)
handle click event of this button in my VBA script
set text of my text control (with tag "text1")
I don't know if it is what you intended, but to add a button in the document, open the Developer tab. Click the Legacy tools folder (in the Controls group) and click the Command Button (Active X Control). This will put a button in the document and make Word go into design mode.
Double-click the new button and you will enter the VBA editor in the event handler for the button.
Enter code to manipulate the text in TextBox1:
TextBox1.Text = "Hi there, VBA master!"
Click the design mode button to exit design mode, and you're good to go; click the new button to set the text.
If you meant to add a button in the ribbon? A little more complicated, but not that hard. Leave a comment, and I'm sure we can work it out as well.