How can I prevent deleting or renaming a worksheet using VSTO? RRS feed

  • Question

  • How can I prevent deleting or renaming a worksheet with predefined name  using VSTO?

    I am creating a Excel AddIn using VSTO, C#?

    Thursday, October 15, 2015 9:15 AM

All replies

  • >>>How can I prevent deleting or renaming a worksheet with predefined name using VSTO?

    Could you tell us what kind of solutlion you was developing, Document-level customizations or VSTO Add-ins?

    Document-level customizations are associated with a specific document,VSTO Add-ins are associated with the application itself.

    You could protect Workbook to prevent deleting or renaming a worksheet, but it will cause workbook cannot be modified at the same time.

    this.Application.ActiveWorkbook.Protect(Type.Missing, true, false);

    For more information, click here to refer about How to: Programmatically Protect Workbooks

    Monday, October 19, 2015 8:19 AM
  • Thanks David for your response.

    I am creating a VSTO AddIns. 

    In my case protecting workbook is not an solution.

    Is there any other solution like revert once found that a filename having predefined name will be renamed back to original name etc.

    Monday, October 19, 2015 8:33 AM
  • Hi Animesh

    You might want to ask in the Excel for Developers forum how the Excel specialists handle something like this...

    Replying, though, to "reverting": You can add a CustomXMLPart to the workbook with any well-formed XML you prefer to store information you want to "enforce" in the workbook. Then monitor certain events, such as saving or printing. Check the settings and reset any changes before allowing the action (save, print, whatever) to procede.

    Cindy Meister, Office Developer/Word MVP, <a href=""> my blog</a>

    Monday, October 19, 2015 1:06 PM
  • Not a real answer but i think these two links can give you some interesting insights :

    Saturday, October 24, 2015 5:55 PM