Tag Archives: UIAutomation

VBA – Ribbon Automation Via UIAutomation

I’ve made a couple posts recently about UIAutomation:

and more.

I had mentioned I would give a few demonstrations of working with the Ribbon, invoking commands and that what this article is about.

Below are simply a series of procedure to accomplish a variety of different things that can be done by using the Ribbon. Demonstrations of interacting with the UI via the UIAutomationClient library.

Continue reading

VBA – UIAutomation – Minimize and Maximize the Office Ribbon

Spring

Just a quick post today and sort of a Part 2 to my previous post:

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

VBA – UIAutomation – Is The MS Office Ribbon Expanded or Collapse?

Measuring Tape

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 might vary from PC to PC, or Edition to Edition, or if Microsoft might randomly change it one day down the road for some reason.  So I decided to explore this a little using UIAutomation.

Continue reading

VBA – Microsoft Access Navigation Pane Automation Via UIAutomation Cont’d

I recently got a comment/question from Access MVP Alum George Hepworth regarding my article and YouTube video:

where he inquired:

Daniel, is there a method to expand or collapse the nodes inside the Nav Pane, i.e. show or hide reports under that node?

Like a dog with a bone, it got me intrigued to the point that I had to resolve it.

Continue reading

VBA – Microsoft Access Navigation Pane Automation Via UIAutomation

A recent question by a fellow MVP made me look at some old code to see if I could solve the issue using VBA UIAutomation.

I’ve briefly touched upon UIAutomation in the past with articles like:

So What Can UIAutomation Do For Us When It Comes To The Navigation Pane?

Well, it can enable us to do things such as:

So let us explore UIAutomation and the Navigation Pane for a moment!

Continue reading

Access – VBA – Set Focus On Specific Document Tab

I was trying to help out in a UA thread:

 

The Question?

The question was:

How can one switch to a specific tab, when using Tab Documents?

Microsoft Access - Document Tabs

Continue reading

VBA – Activate a Specific Ribbon Tab

Target

As part of my article on Compacting the current database:

 

Some users indicated an issue that the code only worked when the Database Tools tab was first activated.

So I wanted to find a way to do this, and I finally did!

Continue reading

Access – VBA – Compact the Current Database

Here’s a functionality that is often asked for:

How can I compact the current database via code (VBA)?

Typically the answer is either:

  • It can’t be done (the functionality was removed, don’t ask me why – ask Microsoft?!)
  • Set the Compact on Close property to True, close the database and then set it back to False when the database is reopened.

What if I told you there was a better way!  Well there is!

Continue reading