I have the window handle - how can i assign it?

George J

Well-known Member
Joined
Feb 15, 2002
Messages
959
I am doing something weird and wonderful (scrambling in the dark) and have the hwnd of a particular window.


Say I have found the handle for the active window and it's a webpage.
Dim myDoc as HTMLDocument
set myDoc = hwnd
then I can access the HTML elements on myDoc

How can I make the code understand that myDoc should be the activewindow? I am trying to extract some URL data on the page.

I found some code that looked promising here but I can't amend it to work for me.
Hope this makes sense.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Loop through Shell.Windows and when it finds an IE window see if the IE.hwnd is the same as your hwnd.
 
Upvote 0
Thanks for that John.

I was hoping to try to get some information from a Chrome popup, but it doesn't look very likely. I managed to get the Window Text returned, but i guess the Shell API won't help with the contents of the window.

Not sure what to do next - will need to think about the steps and process the user will need to take to bypass this. It's going to be messy :eek:
 
Upvote 0
I assumed you were using IE because your code uses HTMLDocument, hence Shell.Windows -> IE -> IE.Document -> HTMLDocument to get text inside the window. AFAIK the HTML Object Library only works with IE, not Chrome or any other browser.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top