Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Vba to activate external window

  • 30-10-2012 04:43PM
    #1
    Closed Accounts Posts: 10,179 ✭✭✭✭


    Hi
    Ive tried googling this to a large extent and searched around but theres no conclusive answer

    Does anyone know how to activate (and then interact with) a window using vba code that was not created by the code?

    So for example a pre existing IE window or a window created manually using sendkeys

    Thanks!


Comments

  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    You have to hook into windows dlls and call the native api to do this, very hacky with vba.

    In banks etc they use various middleware solutions to bridge the gap, there is a product for example that lets you run C# inside excel - which gives a lot more freedom.


  • Closed Accounts Posts: 10,179 ✭✭✭✭Max Power1


    Very hacky? i like the way that sounds lmao. Do you know where I could find a sample code or some instructions/guidelines on this?


  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    Well just do it like you would with c++, find the HWND of the target window and then call normal api functions. With VBA you do the same thing: http://msdn.microsoft.com/en-us/library/office/aa165195(v=office.10).aspx

    Depends what version of office you are running too, the newer ones are more flexible.


Advertisement