Pregunta

I'm modifying the ribbons of an Excel file, hiding all default and context tabs but only show my own tab. However, once any add-in with its own tab(s) is installed, these tabs are still displayed, as I do not know how to address them.

I know you can remove all tabs using <ribbon startFromScratch="true">, but I need to leave them in place (I actually use a getVisible callback to hide them from the user but show them to Admin).

So, following questions:

  1. Is there any way to apply a "default" getVisible callback for all tabs not known (I guess the answer is no)
  2. How can I figure out tabIDs of other add-in tabs
  3. Given that PowerPivot is more and more widespread (esp. in Excel 2013) - what is the tabID for this tab?
¿Fue útil?

Solución

This is an awesome question, there is little documentation or examples about working with third party ribbons. I've done a lot of digging around and can help you with most of what you want. I'll answer you're questions slightly out of order but here goes.

3) The Tab Id for the PowerPivot addin is a qualifier Id (so must be used with idQ) and is tabGemini. You must use it in the name space: Microsoft.AnalysisServices.Modeler.FieldList. You can check this by adding a namespace to the schema:

xmlns:x1="Microsoft.AnalysisServices.Modeler.FieldList"

and then when declaring your tab's id, use the following to insert your tab before the PowerPivot tab:

insertBeforeQ="x1:tabGemini"

2) I had a hard time finding the tab Id for PowerPivot since it's a VSTO COM addin so you can't access the XML like you can with .xlam files. The answer is simple but you need Office 2010 or later. With Excel open and the addin you are interested open too, go to the File Menu and then Options. Choose Customize Ribbon and on the right of the window at the top choose Customize the Ribbon: Main Tabs. Now uncheck the addins you are interested in and down the bottom hit Import/Export to export the XML schema. Open this file up in a text editor and you can see how they've declared their tab ids.

1) I think the trouble you've got with the getVisible call back is that no matter how you mark up your XML if someone loads up an add-in after you, it'll override whatever you've done. The following is from the Fluent Ribbon for Developers FAQ (http://msdn.microsoft.com/en-us/library/office/aa722523%28v=office.12%29.aspx#a16c7df5-93f3-4920-baa8-7b7290794c15_FAQ)

What happens when two add-ins try to repurpose the same built-in control? The last add-in that attempts to repurpose the control becomes the active add-in.

Now I haven't gone any further than this, but if you can import/export this board schema into Office then if you can find where this get's imported into, maybe you could manually overwrite it in VBA using the filescripting object. Obviously only if it's stored as text. Bit of a long shot but worth a further look? Good luck!

Otros consejos

The PowerPivot tab is a COM Add-In. To view the progID of it and other COM Add-Ins use:

Sub ListCOMAddins()
Dim lngRow As Long, objCOMAddin As COMAddIn
lngRow = 1
With ActiveSheet
      For Each objCOMAddin In Application.COMAddIns
         .Cells(lngRow, "A").Value = objCOMAddin.Description
         .Cells(lngRow, "B").Value = objCOMAddin.Connect
         .Cells(lngRow, "C").Value = objCOMAddin.progID
         lngRow = lngRow + 1
      Next objCOMAddin
End With
End Sub`

In my case the progID of the PowerPivot tab is "Microsoft.AnalysisServices.Modeler.FieldList". So to close the tab use:

Private Sub Workbook_Open()

   Application.COMAddIns("Microsoft.AnalysisServices.Modeler.FieldList").Connect = False

End Sub
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top