How to use VBA to detect and click "buttons" in third party applications?

Lexus1

New Member
Joined
Aug 2, 2018
Messages
7
Dear all,

I am an advanced VBA user as far as using it on the default Microsoft office applications is concerned. But currently I am writing a macro where it would be very beneficial to know how to control third party applications from VBA. Up till now I was quite successful using the Sendkeys function to resolve most of my issues but I am sure a lot of you would agree that this solution is suboptimal.

As such my question in this case is very general: which functions should I learn / look into if I want to operate third party applications from VBA? I am looking for sources and general advice in this case. Optimally what I would like to do is to have VBA detect a button within a third party application (e.g. help button in notepad for example) and click it.

Thanks for any help!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Firstly, it’s much easier the third party application is com accessible, if it is, you can set a reference to it and away you go.

If not, you probably want to have a look at the get window and send message windows apis. These allow you to get the pointers to various controls and send messages to them, though the application interface you’re working with may make this very hard.

Finally you’ll want to track down a copy of spy++ this will show you how interfaces are constructed and how you can interact with them.
 
Upvote 0
First thank you for the pointers as to what I should look into.

"it’s much easier the third party application is com accessible, if it is, you can set a reference to it and away you go."- how would I know whether that is the case (I never had the case where that would matter)? Is there a way to test that?

Also another question, as I don't think my initial question covers it, what would I need to use in order to retrieve a value from a third party application form (what I mean here is for example the question whether a box is ticked or not in the form, as I would have to know that in advance (have the macro detect it) as to whether that is the case in order for it to make sense that the sendkeys / sendmessage commands are to be executed)
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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