Click to See Complete Forum and Search --> : How to get the HWnd of Microsoft Word?


mingwah
October 5th, 1999, 09:15 PM
Hello,

My VB program is controlling Microsoft Word via Automation. After starting it up (using CreateObject), I also need to know Word's Window Handle for other forms of processing.

How can I get Word's window handle?

Thanx.
MingWah

suntosh
October 6th, 1999, 12:47 AM
You can use the FindWindow with the combination of the SetWindowPos APIs to accomplish this task.

The FindWindow will return the hWnd of the window that you are looking for and then you can use the SetWindowPos API to bring the focus of that window to the front. Check the syntax for declaration with the API text viewer.

You will have to pass the ClassName or the Window Title for the FindWindow API.