0

How do I disable Excel save button or override it's default functionality? I have a VSTO Excel project, and there is no need to save the Excel Workbook itself because we are using our own ways to save the document data using WCF. It even creates problems for us when user doesn't have writting rights: then he gets a "save as" dialog which still does nothing because I cancel the save event using following code:

void ThisWorkbook_BeforeSave(bool SaveAsUI, ref bool Cancel)
    {
        Cancel = true;
    }

I can also cancel the "do you want to save" prompt using:

 void ThisWorkbook_BeforeClose(ref bool Cancel)
    {
        this.Saved = true;
    }

But if the file is read-only and I click the Save button, then I get a "this file is read-only" message. I don't want to get it.

2 Answers 2

2

If you are using Office 2010 or 2007 you could load a Ribbon that disables the built in commands save and save-as.

The most comprehensive documentation I know for the Ribbon markup is here:

MSDN Customise the Office Fluent Ribbon Interface - 1

MSDN Customise the Office Fluent Ribbon Interface - 2

MSDN Customise the Office Fluent Ribbon Interface - 3

Sign up to request clarification or add additional context in comments.

Comments

0

I figured out that if you create a Template project instead of a Workbook project, then nothing happens when you click Save if my code from the question is applied.

1 Comment

If that works then great but you aren't actually answering your own question. You asked how to disable or override Excel's "Save" button not how to prevent your users from saving over the original sheet, which obviously a template would prevent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.