Just a quick post today and sort of a Part 2 to my previous post:
VBA - Is The MS Office Ribbon Expanded or Collapse?
I’ve been playing around a lot with the UIAutomation library recently and wanted to see if it would be possible to check the status of the Ribbon. Traditionally, to check if the Ribbon was Expanded or Collapsed, people rely on the height, but I don’t like that because I have no clue if that value…
Continue reading →
I thought to myself, now that I can easily and reliably determine if the Ribbon is Expanded or Collapse, wouldn’t it be useful if I could change that (thinking about changing tab and clicking on command – coming soon!).
And so, I started to do some digging and testing.
I was hung up on UIAutomation, and this was a mistake in this instance! Sadly, from what I could determine, UIAutomation does not appear to provide any means to perform mouse click per se. You can retrieve mouse coordinates and get into APIs, but I didn’t want any of that.
I knew we could use
CommandBars.ExecuteMso "MinimizeRibbon"
to minimize the Ribbon, but to maximize it, people often recommend and resort to using things like:
SendKeys "^{F1}", False
but SendKeys are dangerous and should be avoided!
Then, I had a mishap, I ran the minimize command when the Ribbon was already Collapsed, and it Expanded, say what?! And so, the simplest solution ever was created, use he minimize command to both Collapse and Expand the Ribbon.
Continue reading →