PDA

Click to See Complete Forum and Search --> : Getting handle subwindow Word document, STRANGE BEHAVIOR


lvermeersch
Dec 13th, 2005, 01:16 AM
I use Word automation in my VB6 Application
I have to get the handle to a subwindow of an open Word document let say the textbox properties window.
I found how to do it but couldn't get the handle (i get allways zero)
I can only get the handle to he parent word document OpusApp.

The code
'I know i have the correct 10.0 version
Hendel = FindWIndowEx(0,0,"bosa_sdm_Microsoft Word 10.0","")

So i get allways zero and i have the submenu 'FormatTexbox' open
I can get the hendle using GetForegrondwindow but, using this method is useless here, because i have to find the window through the open windows not only the foreground or active one.

Should i use an other API, to look for the submenu class or am i doing something wrong.

RobDog888
Dec 13th, 2005, 09:37 PM
You need to pass the found parent window handle (OPusApp) so it knows to look for a child window of that window.
Hendel = FindWIndowEx(WordHandleGoesHere,0,"bosa_sdm_Microsoft Word 10.0","")

lvermeersch
Dec 16th, 2005, 07:33 AM
Thx for reply.I can get the handle now most of the time. But sometimes get nothing.
I found a very strange behavior. Problem seems to be an execute stop, the command FindWindowEx seems not the problem.

First my situation.
I have a timer (interval at 50)
In the timer i look for the open subwindow using the FindWindowEx command
The problem seems te be that when i open a Save As window in the open Word document sometimes (in 50% of the case) the timercode stops executing. To check this i add a static counter with a textbox. Often the Tel counter doen'st add but stops until i close the doc subwindow 'Save as', then the counter continues?
What can i do about this. I need to continue my code in the timer when subwindow is open. The same effect when i open subwindow Options or other subwindow. Allso setting a shorter timerinterval doesn't improve
-Allso strange is that when the cursor is in a textbox shape of word doc it does allways work!
When cursor is just in the word document itself and not in a textbox or other object this not allways work and executing often stops until i close the subwindow.


Private SUb Timer1_Timer()
Static Tel as Long
Dim Hendel as Long
tel = tel + 1
text22.text = tel
Hendel = FindWindowEx(...)
end sub