Consulting

Results 1 to 6 of 6

Thread: Retrieve contents of Window for use in Excel

  1. #1
    VBAX Mentor Brandtrock's Avatar
    Joined
    Jun 2004
    Location
    Titonka, IA
    Posts
    399
    Location

    Retrieve contents of Window for use in Excel

    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,
    Brandtrock




  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi TJ,

    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...
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  3. #3
    VBAX Mentor Brandtrock's Avatar
    Joined
    Jun 2004
    Location
    Titonka, IA
    Posts
    399
    Location
    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,
    Brandtrock




  4. #4
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    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
    K :-)

  5. #5
    VBAX Mentor Brandtrock's Avatar
    Joined
    Jun 2004
    Location
    Titonka, IA
    Posts
    399
    Location
    Killian,

    Thanks for being able to explain exactly what my problem was to me better than I could myself. 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,
    Brandtrock




  6. #6

    Red face I'm just taking a nebie stab at this

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •