none
What event should I catch in order to disable most ribbon buttons when there is no active worksheet? RRS feed

  • Question

  • What event should I catch in order to disable most ribbon buttons when there is no active worksheet?

    Is there something like Number of Open Worksheets? I need something like that in order to enable/disable the ribbon buttons of my AddIn.

    TIA

    Sunday, May 27, 2018 8:45 PM

Answers

  • Hello Travis,

    The Count property of the Worksheet class returns Long value that represents the number of objects in the collection (Application.Worksheets.Count).

    Also you may be interested in the following events of the Workbook class:

    NewSheet - is fired when a new sheet is created in the workbook.

    SheetBeforeDelete - is fired when any sheet is deleted.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers


    Sunday, May 27, 2018 9:26 PM
  • You can use ribbon callbacks and return always up to date values depending on the count of worksheets.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Sunday, May 27, 2018 9:32 PM
  • No, Ribbon UI callbacks. Event handlers for your custom Fluent UI.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Sunday, May 27, 2018 9:55 PM
  • See relevant comment below by our very own Eugene.   :-)

       https://stackoverflow.com/questions/31262782/what-does-it-mean-to-use-ribbon-callbacks

    • Marked as answer by Travis Banger Monday, May 28, 2018 11:41 PM
    Monday, May 28, 2018 11:41 PM

All replies

  • Hello Travis,

    The Count property of the Worksheet class returns Long value that represents the number of objects in the collection (Application.Worksheets.Count).

    Also you may be interested in the following events of the Workbook class:

    NewSheet - is fired when a new sheet is created in the workbook.

    SheetBeforeDelete - is fired when any sheet is deleted.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers


    Sunday, May 27, 2018 9:26 PM
  • Hello Travis,

    The Count property of the Worksheet class returns Long value that represents the number of objects in the collection (Application.Worksheets.Count).

    Also you may be interested in the following events of the Workbook class:

    NewSheet - is fired when a new sheet is created in the workbook.

    SheetBeforeDelete - is fired when any sheet is deleted.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers


    Thanks, Eugene...

    I was looking for a way to disable the whole ribbon, but the closest I found was to make it invisible. I guess all the ribbon buttons must be initially individually disabled, then.


    Sunday, May 27, 2018 9:31 PM
  • You can use ribbon callbacks and return always up to date values depending on the count of worksheets.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Sunday, May 27, 2018 9:32 PM
  • Eugene: By "ribbon callbacks" you probably are referring to events such as the ones already mentioned: NewSheet, SheetBeforeDelete, etc. ?

    Thanks again.

    Sunday, May 27, 2018 9:54 PM
  • No, Ribbon UI callbacks. Event handlers for your custom Fluent UI.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Sunday, May 27, 2018 9:55 PM
  • See relevant comment below by our very own Eugene.   :-)

       https://stackoverflow.com/questions/31262782/what-does-it-mean-to-use-ribbon-callbacks

    • Marked as answer by Travis Banger Monday, May 28, 2018 11:41 PM
    Monday, May 28, 2018 11:41 PM