none
How can we disable delete and rename option in Ply Context Menu RRS feed

  • Question

  • Hi

    I need to disable delete and Rename option in Ply Context Menu.  I   have tried the below code, but it's not working

      private void ThisWorkbook_Startup(object sender, System.EventArgs e)

            {

       Globals.ThisWorkbook.Application.CommandBars["Ply"].Controls["&Delete"].Enabled = false;

                Globals.ThisWorkbook.Application.CommandBars["Ply"].Controls["&Rename"].Enabled = false;

    }

    but I can able disable the “Insert and Delete option” in Row Context Menu.   

    Please advise me .



    • Edited by Siva2013 Friday, December 7, 2012 4:12 AM for content clear
    Thursday, December 6, 2012 3:20 PM

Answers

  • Hi Sivam

    Starting in Office 2010 the context menus should be customized using the "Office Fluent UI" (Ribbon XML). Actually, for disabling any commands, you should be using a <commands> section in a Ribbon XML in your workbook. That will take care of the commands no matter where the user tries to invoke them - in that workbook, only.

    You can download a listing of all the Office 2010 Control IDs here:
    http://www.microsoft.com/en-us/download/details.aspx?id=6627

    Search for these two commands, then use them as described in these articles:
    http://msdn.microsoft.com/en-us/library/office/bb462633(v=office.12).aspx
    http://msdn.microsoft.com/en-us/library/office/ee633442(v=office.11).aspx


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, December 7, 2012 1:52 PM
    Moderator
  • Hi Cindy

    Thanks for your reply.

    Now i can able hide button in ply content menu. I did on Ribbon.XML file.

    <contextMenu idMso="ContextMenuWorkbookPly">

                         <button idMso="SheetInsertPage"  enabled="false" />

                         <button idMso="SheetDelete"  enabled="false" />

                         <button idMso="SheetRename"  enabled="false" />

                         <button idMso="SheetMoveOrCopy"  enabled="false" />

                         <button idMso="SheetProtect"  enabled="false" />

                         <button idMso="ViewVisualBasicCode"  enabled="false" />                            </contextMenu>

    Now I have one more question. I try to same way to Row Context Menu and columns Context Menu button in Ribbon.XML, but it is not working. I used the Excel control ID which is downloaded from the Microsoft site.  I am sharing to you.   http://sdrv.ms/VCHCYH

    Pleas e download it .

    With best Regards

    Sivam

    Thursday, December 13, 2012 2:44 PM

All replies

  • Which version of Excel?

    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, December 6, 2012 8:20 PM
    Moderator
  • Hi

    I am using Excel VSTO 2010 

    Friday, December 7, 2012 4:07 AM
  • Hi Sivam

    Starting in Office 2010 the context menus should be customized using the "Office Fluent UI" (Ribbon XML). Actually, for disabling any commands, you should be using a <commands> section in a Ribbon XML in your workbook. That will take care of the commands no matter where the user tries to invoke them - in that workbook, only.

    You can download a listing of all the Office 2010 Control IDs here:
    http://www.microsoft.com/en-us/download/details.aspx?id=6627

    Search for these two commands, then use them as described in these articles:
    http://msdn.microsoft.com/en-us/library/office/bb462633(v=office.12).aspx
    http://msdn.microsoft.com/en-us/library/office/ee633442(v=office.11).aspx


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, December 7, 2012 1:52 PM
    Moderator
  • Hi Cindy

    Thanks for your reply.

    Now i can able hide button in ply content menu. I did on Ribbon.XML file.

    <contextMenu idMso="ContextMenuWorkbookPly">

                         <button idMso="SheetInsertPage"  enabled="false" />

                         <button idMso="SheetDelete"  enabled="false" />

                         <button idMso="SheetRename"  enabled="false" />

                         <button idMso="SheetMoveOrCopy"  enabled="false" />

                         <button idMso="SheetProtect"  enabled="false" />

                         <button idMso="ViewVisualBasicCode"  enabled="false" />                            </contextMenu>

    Now I have one more question. I try to same way to Row Context Menu and columns Context Menu button in Ribbon.XML, but it is not working. I used the Excel control ID which is downloaded from the Microsoft site.  I am sharing to you.   http://sdrv.ms/VCHCYH

    Pleas e download it .

    With best Regards

    Sivam

    Thursday, December 13, 2012 2:44 PM
  • Hi Sivam

    Please start a new discussion (of type question) for this new problem. Don't forget to include the version of Excel.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, December 13, 2012 4:45 PM
    Moderator