Visio 2010 Context Menus

Started by AndyW, November 22, 2011, 03:08:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AndyW

Anyone succeed in customising the Page Tab via the ribbon using ContextMenuPageTabs.

<contextMenus>
    <contextMenu idMso="ContextMenuPageTab">
        <button id="MyButton" label="Mine" onAction="OnAction"/>
    </contextMenu>
</contextMenus>

Once I add this in, Visio doesn't like the customUI xml.
Live life with an open mind


Nikolay

#2
Quote from: AndyW on November 22, 2011, 03:08:12 PM
Anyone succeed in customising the Page Tab via the ribbon using ContextMenuPageTabs.

<contextMenus>
    <contextMenu idMso="ContextMenuPageTab">
        <button id="MyButton" label="Mine" onAction="OnAction"/>
    </contextMenu>
</contextMenus>

Once I add this in, Visio doesn't like the customUI xml.

Make sure you add that after the <ribbon> part.
Also make sure you use Office 2010 namespace, not Office 2007:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"

AndyW

Thanks al, I had been using those resources.

Nikolay, I updated to the Office 2010 namespace, but no difference.

<?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="OnRibbonLoad" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon startFromScratch="true">
        <tabs>
            <tab id="PCMD_Ribbon" label="PCMD">
                <group id="managementGroup">
                       <button id="ManagementB" label="Management" showImage="false" onAction="OnAction" />
</group>
                <group id="zoomGroup" label="Zoom">
    <control idMso="ZoomClassic" visible="true"/>
                    <buttonGroup id="zoomBGrp">
                        <control idMso="ZoomIn" showLabel="true" visible="true" />
                        <control idMso="ZoomOut" showLabel="true" visible="true" />
                    </buttonGroup>
                    <button id="RefreshDiagram" imageMso="ZoomFitToWindowVisio" label="Whole Page" visible="true" onAction="OnAction"/>
                </group>
            </tab>
        </tabs>
    </ribbon>
    <contextMenus>
<contextMenu idMso="ContextMenuPageTab" visible="false">
</contextMenu>
    </contextMenus>
</customUI>
Live life with an open mind

Nikolay

#4
It seems that you code worked for me... I mean, if I paste this fragment:

<contextMenus>
  <contextMenu idMso="ContextMenuPageTab">
    <button id="MyButton" label="Mine" onAction="OnAction"/>
  </contextMenu>
</contextMenus>

I get the "Mine" menu item in the page context menu.

However if I use be below code fragment, I get validation error that "visible" is not valid for "contextMenu", i.e. probably you should remove it.
If I remove visible, it seems to work.

<contextMenus>
  <contextMenu idMso="ContextMenuPageTab" visible="false">
  </contextMenu>
</contextMenus>

Note that Visual Studio does validation quite nicely if you select proper XSD file as file schema - in this case validation and autocomplete will work for the ribbon XML ;)

AndyW

Thanks, I added visible in earlier just to try it. Took that out and added a button and it worked!

Think it was the schema as you suggested.

Do you know what the idMso for the existing items are, i.e. Insert Page etc as I wish to catch these and do additional processing.

At the moment I am prototyping with 2010 so this is being done on a PC without Visual Studio, my build PC has Visual Studio but only has Visio 2003 as that's the minimum version I support. And thought it was safer not to put Visio 2010 in case it affects my 2003 builds.
Live life with an open mind

Nikolay


AndyW

Hmm, not sure why I didn't find your earlier post when I search.

How do we find the idMso for the items in the context menus? Insert Page, Delete Page, Rename Page and Reorder Pages.

Also, the page tabs have an insert new page tab on the end, do you know if that can be customised?

Thanks for your help.
Live life with an open mind

Nikolay

Quote from: AndyW on November 23, 2011, 08:47:29 AM
How do we find the idMso for the items in the context menus? Insert Page, Delete Page, Rename Page and Reorder Pages.

I just searched that excel file... Maybe there is a better way though :)
BTW, I don't think you can overwrite/extend default commands that way, that is I don't think you will be able to "add extra processing" to a built-in command using the ribbon customization file. But maybe I misunderstood something.

Quote from: AndyW on November 23, 2011, 08:47:29 AM
Also, the page tabs have an insert new page tab on the end, do you know if that can be customised?

Not sure.