Outlook VBA and hWnd

prophet001
prophet001 used Ask the Experts™
on
Hi,
 I was wanting to know if it's possible to find the hWnd of a Microsoft Outlook 2007 program without the use of FindWindow. FindWindow using the window caption to find the handle. That seems like a poor solution to me. What if there are two windows that have the same caption? The caption is not a unique identifier.

Here is my scenario. I want to supply a handle to the GetFileName API function that is a form in Outlook. I know that I could specify a unique form name and that it would most likely never result in a wrong assignment of the handle with FindWindow but is there another way?

Thank you for any help that you can give,
 Preston
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006

Commented:
this code uses GetWindowText which is a similar thing I guess. Perhaps maybe work with the sample code here
http://www.vbforums.com/showthread.php?t=153818

I looked at using GetObject but although I got the outlook instance that was running, I was unable to find the windows handle

Author

Commented:
Hey Rocki,
 Thank you for your response. If you read the MSDN documentation on those API calls it says that FindWindow uses GetWindowText so in essence you would be doing the same thing. I know that GetWindowText would allow you to iterate child windows but so would FindWindowEx.

I might be trying to solve a problem that doesn't exist if FindWindow is hierarchy specific then it will most likely never encounter conflicting windows.

Anyway, for so much reliance on hWnd the Windows API seems a bit lacking in its methods to discover it.

Anymore help or viewpoints would be much appreciated.

Again, Thank you :)
Preston
Top Expert 2006

Commented:
I was trying this initially

dim objOutlook as object

set objOutlook = getobject("", "Outlook.Applicaton")

this returns the object (outlook.application object) if outlook is running

I tried to find hwnd from here, but couldnt find it. reading up it mentioned usine OleWindow from the inspector. I found ActiveInspector in this object but not much else.

As of the closing of this post no consistent way was provided to discover the hWnd of a window apart from using the window's title.

Author

Commented:
no solution provided

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial