0

I'm trying to prevent users from sorting a table in an Excel sheet where I'm heavily using VSTO. I already have a button that allows them to unlock the sheet to sort, however not everyone remembers to press this.

Excel eventually shows a warning box (Cannot sort locked sheet , etc.) however this error message can take minutes to appear, while the user sits looking at the spinning wheel of death.

I would love to intercept the sort command, but I can't seem to fin any way of doing this. Does anyone have a suggestion?

DaveA
  • 187
  • 1
  • 13
  • Possible duplicate of [How to intercept clicking of a built-in Office Ribbon control](https://stackoverflow.com/questions/21172103/how-to-intercept-clicking-of-a-built-in-office-ribbon-control) – Chris Feb 14 '18 at 18:07
  • This may work. The clicking is actually happening on the first data row, but I'll investigate and see if I can get this solution to work. Thanks for forwarding the link! – DaveA Feb 16 '18 at 06:01
  • I actually tried to get this to work using the strategy in that link but was unable to. I was using the sort buttons on the ribbon though; if there's another inline button it might be a different story I guess. Typically when intercepting things in Office the end result is that you can't do it. – Chris Feb 16 '18 at 14:23
  • Thanks Chris. Yes, thats my experience also. There are just some things that are not possible with an Addin hosted within Excel. I might try a quick proof of concept application to see if this is possible before trying with my main app. I've done a hacky workaround whereby the minute a user clicks in the heading row, the worksheet is unlocked (and locked again when another cell is selected). Seems most people click on the heading row before sorting so it will mitigate 50% of users. – DaveA Feb 19 '18 at 21:40

0 Answers0