PDA

View Full Version : Extracting values from an Application



surya prakash
12-07-2007, 03:22 AM
Hi,

I am wondering if it is possible to extract values from various controls (such as textboxes, comboboxes) of an application that is running from Excel VBA and copy these values to excel...

The purpose is for automated testing...

thanks

Simon Lloyd
12-07-2007, 03:27 AM
if the textboxes etc are on a userform range("A1").value = Userform1.textbox1.value as long as the userform hasn't been unloaded, if its a worksheet then Range("A1").value = Sheets("Sheet1").TextBox1.Value

surya prakash
12-07-2007, 04:07 AM
Hello Simon,

Thank you for your response.

I am looking to extract data from an application (say the one developed using VB.Net)

The solution that you have given extracts from the form available in the same excel form..

thanks

Bob Phillips
12-07-2007, 04:50 AM
You would have to create an interface between that app and VBA, assuming that you instantiate the apop from VBA. Without any detail it is very difficult to say how you would do that.

surya prakash
12-07-2007, 04:52 AM
Hi Xld,
There is actually no interface between Excel and the test application.
I believe there are some API calls in C/C++ that would enable a user to extract data without interface.
I am wondering if this is possible in VBA?

thanks

Bob Phillips
12-07-2007, 06:37 AM
What? Are you saying that you have an application running under its own auspices, and you think you can just dive in from a disconnected app and grab data from within that app?

If it can be done, I would be amazed at an incredible security hole, and I certainly don't know how to do it.

rory
12-07-2007, 07:00 AM
You might be able to do it using the FindWindowEx and SendMessage APIs if the controls have their own window handles (if you had a tool like Spy++ you could find out) and if you knew the required window classes: see here (http://www.vbforums.com/archive/index.php/t-297107.html)for an example of the sort of thing. I suspect it would be pretty much impossible for us to come up with the code without having the application though.

surya prakash
12-09-2007, 08:20 AM
You might be able to do it using the FindWindowEx and SendMessage APIs if the controls have their own window handles (if you had a tool like Spy++ you could find out) and if you knew the required window classes: see here (http://www.vbforums.com/archive/index.php/t-297107.html)for an example of the sort of thing. I suspect it would be pretty much impossible for us to come up with the code without having the application though.

Thank you Rory and Xld for your responses.

I know that there are API's (such as Sendmessage ) in C/C++ where it is possible to extract data from a different app.

Rory, Let me have a look at the link that you have given and revert back.

In the meantime, I look forward to hear more from you guys....

thanks