I am trying to execute a macro when a particular submenu exists. I can't get the "If menu exists" logic to identify any menus at any level. I am working in Excel, but I have tested this simple macro in multiple apps.
The macro runs but it never finds the menu.
How do I get KM to return TRUE if a menu exists?
I think this is because it's looking for a menu item -- the things inside the menus. So "Edit" won't be found, but "Copy" -- a menu item within the "Edit" menu -- will be.
A quick test suggests you can use "with path" instead of "with name", and just put in "Edit".
Your submenu should be easier to do using "with this name" as it will be a menu item -- but you could use a path for that too -- see the wiki for how.
That did it Changing "exists" to "with path" did the trick. Works even better since I am actually looking for a menu with a path "Tools > Protection / Unprotect Sheet…" so a path is what I was looking for anyway.
[Update] Now that I see how it works, I see the error of my ways, I assumed the KM Action "If menu exists" would need to work it's way through the menu hierarchy to find a submenu. That turns out to not be true.
My original implementation works with "If menu exists" - with just the final, nested submenu item that I was looking for. KM finds it wherever it happens to be buried (in this case, under Excel's Tools menu).