How to run Outlook macro with UI vision using vbs and shorcut key

This is the way :slight_smile:
If you already have a macro in Outlook, first you need to create a button for that macro on Quick Access Toolbar.
Right click on Quick Access Toolbar → Customize Quick Access Toolbar.
Choose commands from → select Macros → Add Macro to Quick Access Toolbar

!!!NOTE: If you press Alt in Outlook you will see the shortcut key to your button. In my case it was number 4. So the shortcut for UI vision is Xtype | ${KEY_ALT},${KEY_NUM4}

Now create a .vbs file with following script:

Set WShell = WScript.CreateObject(“WScript.Shell”)
Set xlApp = CreateObject(“Outlook.Application”)
xlApp.ActiveExplorer.Activate
WShell.AppActivate (“Inbox - john.doej@domain.com - Outlook”)

If there is Outlook already open, it is now activated and on the foreground.
If you need to start Outlook first, you can use UI vision json:

{
  "Command": "XRun",
  "Target": "C:\\Program Files\\Microsoft Office\\root\\Office16\\OUTLOOK.EXE",
  "Value": "",
  "Description": ""
},

UI vision json for running Outlook macro will be:

{
“Name”: “RunOutlookMacro”,
“CreationDate”: “2022-2-12”,
“Commands”: [
{
“Command”: “XRun”,
“Target”: “Enter path to .vbs file”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “XType”,
“Target”: “${KEY_ALT}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “500”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “XType”,
“Target”: “${KEY_NUM4}”,
“Value”: “”,
“Description”: “”
}

Key_Num4 should be changed to whatever the shortcut number is in Outlook.