PDA

View Full Version : Retrieve contents of Window for use in Excel



Brandtrock
10-11-2005, 04:06 PM
A third party application I am using creates output in a window. I'm drawing a blank as to how to get that information into Excel without saving it first. The application doesn't have the capability of sending it's output to anything but the screen. The window it creates has a print button and a close button, that's it.

Can someone please help me see the forest? All of these trees are getting in my way!!

I'm quite certain I am making this much more difficult than it needs to be, but I'm stuck. That's way hard to admit, btw.

Thanks in advance,

MOS MASTER
10-13-2005, 02:19 PM
Hi TJ, :yes

Wel really don't have a clue cause I don't know the app.

Can you manipulate the window with keystrokes? (Tab to select | Ctrl+A to select the text | Ctrl+C to copy..etc..)

In that case Sendkeys might help....But I'm pretty sure I'm as much in the dark as you are now...:whistle:

Brandtrock
10-13-2005, 04:25 PM
Thanks Joost.

Manipulating by keystrokes works, I just haven't had much success getting Sendkeys to be reliable.

I have used Mark007's KB to ID the window handle, title etc, but have not figured out how to get the contents under my control yet.

Thanks for the reply,

Killian
10-14-2005, 02:48 AM
hmmm... I don't think you're making it more difficult than it is - it's a tricky one.
Sendkeys is somewhat unreliable which is why it should only ever be the weapon of last resort (and not used in distributed code)
Getting a handle to the window will only allow you to access the aspects that Windows manages - bear in mind that a "window" is only a data structure in memory that is linked to an application. It follows the rules Windows lays down and has to provide certain properties (like the window status, title bar text etc) in order for the window to be rendered on screen but it's the application class that defines the content of the window and the rest of the communication with the OS is achieved by messages sent to Windows from the application class.
Unless a specific interface in written into the application, the only messages that go the other way relate to the control of the window (minimizing, destroying, refreshing) and the user interface (mouse and keyboard), which is why SendKeys looks like the only option :-(

You mention the app has a print button... is there any way you could utilise that? If you can print to file, Excel can open text only .prn files and you can parse the info from there. But unless the app has some command line options, I suppose you'll still need to use SendKeys to do the print

Brandtrock
10-14-2005, 09:10 AM
Killian,

Thanks for being able to explain exactly what my problem was to me better than I could myself. :thumb Since this will be a routine for a client, the low confidence in Sendkeys is bothering me. I, too, was hoping the print button could be a "backdoor" way to getting the data from the app to Excel. I'll tinker with that a bit more.

If I do get something figured out, I'll post back with the solution.

I'm not gonna marked this solved just yet though, just in case any other suggestions come up.

Thanks for the info!

Regards,

EdCompSci
03-19-2006, 06:42 PM
Is it necessary to first convert the page to XML and then have VBA read in the XML? Or if it's not necessary is it a good way of doing it?


-Edward
below is my really outdated website; hopefully someday I'll get back to working on it.
http://www.edwardtisdale.com (http://www.edwardtisdale.com/)