Doorgaan naar hoofdcontent

Excel: Creating Your Own Tabs With XML And VBA

In order to create you own nice looking tabs you need the Custom UI Editor for Microsoft Office. You can download it for free.

How is this different from choosing File, Options, Customize Ribbon and adding a new tab with new groups and then commands to the group? You can also move the new tab to any position. Then your new tab is always there. Even when you don't open the specific file with the right VBA.

In my example the outcome looks like this, a nice tab, placed in front of the Home Tab. You will only get this tab when you start the specific example (which you can download).


The XML behind this:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
   <ribbon startFromScratch="false">
    <tabs>
      <tab id="MaxIlze" label="Dossier Overzicht" insertBeforeMso="TabHome">
        <group id="customGroup1" label="Adressen verrijken">
          <button id="customButton1" label="Adressen toevoegen" size="large" 
onAction="toevoegenpchnr" imageMso="QueryAppend" />
         <button id="customButton2" label="Gegevens toevoegen" size="large" 
onAction="vullen" imageMso="DatabaseAccessBackEnd"/>
         <button id="customButton3" label="Adres zoeken" size="large" 
onAction="zoekenpostcode" imageMso="FindDialog"/>
         <button id="customButton4" label="Dossier zoeken" size="large" 
onAction="zoekendossier" imageMso="FindDialog"/>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

Comments

  • insertBeforeMso="TabHome" will place the tab before the Home Tab
  • onAction="toevoegenpchnr" refers to the VBA behind the file
  • imageMso="QueryAppend" refers to the Microsoft buttons; you could use image to refer to you own buttons
  • label="Adressen toevoegen" refers to the label underneath the buttons
The VBA behind the file:


Sub toevoegenpchnr(control As IRibbonControl)
    MsgBox "toevoegen"
End Sub

Sub vullen(control As IRibbonControl)
    MsgBox "vullen"
End Sub

Sub zoekenpostcode(control As IRibbonControl)
    MsgBox "zoeken postcode"
End Sub

Sub zoekendossier(control As IRibbonControl)
    MsgBox "zoeken dossier"
End Sub

Comment
  • control As IRibbonControl, this needs to be added to the VBA procedure

Reacties

Populaire posts van deze blog

Excel: VBA script om wachtwoord te verwijderen

Af en toe krijg ik een vraag om een wachtwoord van een Excel blad te halen. Doodsimpel met VBA. Hier een script dat ik gebruik: Sub WachtwoordCrack()     Dim a As Integer, b As Integer, c As Integer, d As Integer, _     e As Integer, f As Integer, g As Integer, h As Integer, _  I As Integer, j As Integer, k, m As Integer     Dim begin As Date, eind As Date     Dim duur As String     Dim objSheet As Worksheet     begin = TimeValue(Time)     On Error Resume Next     For Each objSheet In Application.Worksheets         For a = 65 To 66: For b = 65 To 66: For c = 65 To 66             For d = 65 To 66: For e = 65 To 66: For f = 65 To 66                 For g = 65 To 66: For h = 65 To 66: For I = 65 To 66                     For j = 65 To 66: For k = 65 To...

Excel 2013: uniek aantal in draaitabel

Tot en met versie 2010 was het in Excel lastig om in een draaitabel een uniek aantal (DISTINCT COUNT) te tellen. We geven een voorbeeld op basis van een verkoperslijst. In deze lijst kunnen we zien welke verkopers welke artikelen hebben verkocht. Willen we nu in een draaitabel laten zien hoeveel artikelen een verkoper heeft verkocht, dan krijgen we wel de aantallen maar niet de unieke aantallen te zien. Om toch de unieke aantallen te laten zien, hebben we een aantal stappen nodig. Op het moment dat we de draaitabel invoegen, krijgen we in Excel 2013 dit dialoogvenster: Onderaan zien we daar een nieuwe optie: Deze gegevens toevoegen aan het gegevensmodel . Deze optie moeten we aanvinken, voor we op OK klikken. We krijgen dan een iets ander beeld dan normaal: Normaliter krijgen we alleen de veldnamen. Nu zien we er het woord Bereik boven staan. Voor het voorbeeld heb ik nu Verkoper toegevoegd aan Rijen en Artikelomschrijving aan Waarden . Het resultaat is identiek...

Excel: gegevenslabel alleen bij de laatste waarde in een grafiek

Creatief met Corona Bij het maken van een grafiek over de voortschrijdende Corona cijfers in Nederland liep ik tegen een probleem aan. Als je bij een reeks gegevens in een grafiek de gegevenslabels aan zet, krijg je die labels bij elke waarde. Ik wilde dit label alleen bij de laatste waarde tonen. Nu kun je natuurlijk alle andere gegevenslabels afzonderlijk wissen, maar dat is een hoop werk. Op zoek naar een andere manier dus. De cijfers datum aantal 1-3-2020 3 2-3-2020 8 3-3-2020 5 4-3-2020 15 5-3-2020 44 6-3-2020 46 7-3-2020 60 8-3-2020 76 9-3-2020 57 10-3-2020 61 11-3-2020 121 12-3-2020 111 13-3-2020 190 14-3-2020 155 15-3-2020 176 16-3-2020 278 17-3-2020 292 18-3-2020 250 19-3-2020 20-3-2020 21-3-2020 22-3-2020 23-3-2020 24-3-2020 25-3-2020 ...