Get hWnd of the main Word, Excel, PowerPoint window?

D

David Thielen

D

Dmitry Streblechenko

I don't think any Office app except Outlook implements the IOleWindow
interface which can be used to call IOleWindow::GetWindow().

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
S

Scott McPhillips [MVP]

David Thielen said:
Hi;

Is there a way to get the main hWnd other than enum all windows by
class, and then setting the caption of the Application object to see
if the given window of that class has the same caption?

I ask because sometimes the SetCaption call throws an exception and
then this approach does not work.

thanks - dave


Setting the caption should not be necessary, since you know (or can get) the
document name for the window of interest. What I do is enum all windows by
class, comparing the caption to the known document name.
 
D

David Thielen

We tried that but it hit two problems:

1) what if I have open c:\test\dave.docx and c:\data\dave.docx?

2) for some locales the caption is different - I think it was the
Hebrew version where it came back much different than what we see in
the US English version.

thanks - dave


Setting the caption should not be necessary, since you know (or can get) the
document name for the window of interest. What I do is enum all windows by
class, comparing the caption to the known document name.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top