How to get handle of menu in external application, and find button where no text is part of class.

Galaxea

New Member
Joined
Jul 20, 2018
Messages
34
Office Version
  1. 2021
Platform
  1. Windows
@Jaafar Tribak - I have seen that you have extensive experience in this topic so I am hoping that you can help me please.

I have an external application that I can launch and control from Excel, but only up to a point.
As soon as I click on the SEND TO button and the menu pops up I can't go any further as I cannot get the handle or any other info.
Even bringing up the SPY++ tool will make the menu disappear as soon as the focus is changed off the menu.

Please contact me, even off the forum if necessary as I really need to get this working! I can't see a way to contact someone directly on this forum.

1658424498840.png


I have another similar issue with the latest version of the same program (I am in the process of upgrading to it) where I can't find enough info to know what to click to open a company file (see below).
Thanks. Rob.

1658425416226.png
 
1658742788119.png


1658742814483.png


My next issue is that as soon as the popup menu is displayed (after the SendMessage - Click above) the VBA app hangs with the blue circle until I have selected a menu option and then clicked Cancel on the screen after that. The code does not continue, so I can't run any code to detect the popup menu using UIAutomation.
Please advise John!

UPDATE: I tried POSTMESSAGE and that seems to have worked.
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
@John_w : John, I see that the web page that you used in your original IE11 demo is not there any more so it is a bit difficult to get the code working. Do you have another example that works please?
 
Upvote 0
It means the UIAutomation object variable is not defined, i.e. Nothing. Remember, I said that my last code didn't declare or define/get all required objects - look at the Calculator code for the required lines.

You want:
VBA Code:
    Dim UIAutomation As IUIAutomation
    Dim Desktop As IUIAutomationElement
    
    'Create UIAutomation object
    
    Set UIAutomation= New CUIAutomation
    
    With UIAutomation
        Set Desktop = .GetRootElement
        Set NameAndType = <rest of the statement, as above>
    End With
 
Upvote 0
Sorry, I missed that bit.
This next error looks slightly different. Is this the expected response when something is not found?



1658776374897.png
 
Upvote 0
@John_w : John, I see that the web page that you used in your original IE11 demo is not there any more so it is a bit difficult to get the code working. Do you have another example that works please?

I've updated the IE test routine with a URL that works today and made a minor change to the UIAutomation code:

 
Upvote 0
I am getting really close now. John, does the "MenuItems" element need to be defined? I tried to dim it as an element but that did not help. I also tried to set the element number index to 2 in case it was zero-based but no luck there either. Please advise. Thanks!


1658819762626.png
 
Upvote 0
does the "MenuItems" element need to be defined? I tried to dim it as an element but that did not help. I also tried to set the element number index to 2 in case it was zero-based but no luck there either. Please advise. Thanks!
Sorry, I omitted the declaration of MenuItems in my previous posts.
VBA Code:
    Dim MenuItems As IUIAutomationElementArray
The array is one-based.

Sorry for giving you bits of code, but I've got nothing concrete to work with. Most of the declarations etc. you need should be in the Calculator and IE11 examples. The latter thread also has a lot of UIAutomation debugging code to output elements in a hierarchical format to sheet cells.
 
Upvote 0
Please don't apologize - I would be lost without you!
It is still not happy with something though.
Assuming that we get that line to work, what would be the statement that I use to "click" that third menu item, please John?

1658831965661.png
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,215
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top