Keep selected text selected in Outlook

I'm using Outlook for Mac. I want to write a Keyboard Maestro macro to toggle highlighting text yellow on a keyboard tap ie highlight the text if current selection isn't highlighted and un-highlight if current selection already has highlighting

When I select some text in Outlook and tap the highlight button in the Outlook ribbon, the text ive selected is correctly yellow highlighted as I want. My macro will replicate this. The problem is that Outlook by default doesn't keep that original text selected. As soon as I tap the highlight button, the text is no longer selected and Outlook puts the cursor at the beginning of that previously highlighted text.

Is there a way I can get Keyboard Maestro to re-select the original text that I selected before I tap the Outlook highlight ribbon button ?

There's a good chance that someone is here who will have a better way than I have. So maybe my advice can be ignored if a better way is offered.

I don't have Outlook, but I have other apps like Notes, and I was able to basically achieve what you want to achieve by "counting" the number of characters in the clipboard, (I had to press the Copy key in order to get the text into the clipboard) and then pressing SHIFT-ARROW the same number of times to restore the selection. My macro also pressed the space key, but you shouldn't have to do this because you aren't doing a Cut command. I chose to do a Cut to simulate the loss of the selection like you get in Outlook.

In addition, there's the issue of triggering the highlight feature in Outlook. I don't have Outlook so I couldn't prepare that part of the macro for you. If you need help with that, I'm sure someone else who has Outlook can help.

1 Like

No -- it puts the insertion point at the end of the selection. Selecting left-to-right is different to right-to-left. So you'll either need to be consistent in the way you select things or you'll need two versions of @Airy's excellent macro.

I didn't know that either. Wow, not only do I learn something every day, but I learn something from you every day.

1 Like

I've only tried it in Outlook, where the location of the insertion point -- after highlighting hasdeselected the current selection -- follows those rules. So possibly not worth knowing unless you use Outlook!