Reading a text from a textbox of an external application RRS feed

  • Question

  • Suppose there is a GUI running on my machine. This GUI is written in VB.NET but I don't have access to its source code. I want an Excel VBA Macro to read the text of a particular TextBox on that GUI. I tried both GetWindowText and SendMessage(WM_GETTEXT,...). GetWindowText would return the text of Labels (strings on the mask) but not the text  of the textboxes. SendMessage(WM_GETTEXT, ...) doesnt work at all. WM_GETTEXTLENGTH works for the textlength. Do you have an idea what might be wrong?

    Soli Deo Gloria

    Monday, October 13, 2014 3:45 PM

All replies

  • Hi,

    Thank you for posting in the MSDN Forum.

    According to your description, you want to use VBA code to read the text of a particular TextBox on a GUI. I think your requirement is more related to VBA language instead of Excel development, I'd like to move it to VBA forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thanks for your understanding.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 14, 2014 2:44 AM
  • It's difficult to make suggestions as you didn't give your code that apparently doesn't work. However If WM_GETTEXTLENGTH returns the expected length it sounds like you've got the right window, so guessing, did you pre-size a buffer with the result of WM_GETTEXTLENGTH and pass both the length and buffer with WM_GETTEXT. Or alternatively, pass an oversize buffer and its length, and find the Chr(0) that marks the end of the text.
    Wednesday, October 15, 2014 12:51 PM