vbams-wordword-2010

How do I write a macro that has the functionality as Mark Entry button of the References tab in Word Ribbon bar


I need to create a ribbon bar button which will work as a shortcut for the Mark Entry button of the Index group on the References tab. I searched for ways to do this. But I was unable to find any macro which will do this.

This can be done by adding the ribbon bar button in the xml using the following code.

<button idMso="IndexMarkEntry" label="Index entry" />

But I need to put another image as the button icon image. If I use the idmso, I cant use the icon image I want. So I need to find another way to add this button. I have to write a vb custom routine to replace Mark Entry, but I don't know what to write. Can anyone help?


Solution

  • I added the functionality to work as a shortcut for the 'Mark Entry button of the Index group on the References tab' and added the custom image as icon to the ribbon bar button (Index entry) that I have created.

    Open the .dotm file in Custom UI editor and add the custom image icon to the customUI.xml.

    This should be added in the customUI.xml :

    <button id="IndexEntry" size = "normal" label="Index entry" onAction="Ribbon.TPS_IndexEntry" image="Index-entry_16" screentip="Mark Entry (Alt+Shift+X)" supertip="Add the selected text to the index" keytip="IE" />
    

    Open the .dotm and open the developer view of the template. Insert this under Ribbon :

    Public Sub TPS_IndexEntry(ByVal Control As IRibbonControl)
    Word.Application.Run "TPS_IndexEntry"
    End Sub
    

    Then insert this under Macros :

    Public Sub TPS_IndexEntry()
    Dialogs(wdDialogMarkIndexEntry).Show
    End Sub
    

    This will generate a ribbon bar button which will work as a short cut to the Mark Entry button.