0

I'm trying to create an excel document that communications with one of our external apps.

I have sendmessage working well in order to WM_GETTEXT from a specific window, however i can't get to the next childwindow as the class names are all the same:

enter image description here

My first code grabs the text from the very first class under the parentwindow named "WindowsForms10.EDIT.app.0.2004eee"

 Grange = FindWindow(vbNullString, "General Account Enquiry")
 Account_number = FindWindowEx(Grange, 0&,   "WindowsForms10.EDIT.app.0.2004eee", vbNullString)

 the_count = SendMessage(Account_number, WM_GETTEXTLENGTH, 0&, 0&)

 Buffer$ = Space$(the_count)
 Call SendMessageByString(Account_number, WM_GETTEXT, the_count + 1, Buffer$)

But i need to also grab the text from the circled red box, which has the same class name. I only have experience with API calls where the class names are unique.

I've been told by a very helpful stackoverflow contributor to use enumchildwindows to cycle through the 5 other child windows of the same name, but after a few days searching i havn't been able to find the right code to do this.

Is anyone able to help or provide an example code that i can work with?

Thank you very much

1 Answer 1

2

Looks like i managed to figure it out about 5 minutes after posting this,

Grange = FindWindow(vbNullString, "General Account Enquiry")

Account_number = FindWindowEx(Grange, 0&, "WindowsForms10.EDIT.app.0.2004eee", vbNullString)
Account_number2 = FindWindowEx(Grange, Account_number, "WindowsForms10.EDIT.app.0.2004eee", vbNullString)
Account_number3 = FindWindowEx(Grange, Account_number2, "WindowsForms10.EDIT.app.0.2004eee", vbNullString)
Account_number4 = FindWindowEx(Grange, Account_number3, "WindowsForms10.EDIT.app.0.2004eee", vbNullString)
Account_number5 = FindWindowEx(Grange, Account_number4, "WindowsForms10.EDIT.app.0.2004eee", vbNullString)
Account_number6 = FindWindowEx(Grange, Account_number5, "WindowsForms10.EDIT.app.0.2004eee", vbNullString)
Account_number7 = FindWindowEx(Grange, Account_number6, "WindowsForms10.EDIT.app.0.2004eee", vbNullString)

the_count = SendMessage(Account_number6, WM_GETTEXTLENGTH, 0&, 0&)

Buffer$ = Space$(the_count)
Call SendMessageByString(Account_number6, WM_GETTEXT, the_count + 1, Buffer$)

ThisWorkbook.Sheets("Sheet1").Range("A2") = Buffer$
Sign up to request clarification or add additional context in comments.

1 Comment

It would be helpful if you included the declarations of your API functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.