Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how to get hwnd from application object?


Hi:

I am using Excel from another app using COM/OLE. I need
to bring the Excel window to the foreground. Is there any way
to the hWnd from the Application object? Now I use the
FindWindow API call to find the Excel window
but that is not foolproof.

Thanks, Erwin


----------------------------------------------------------------
Erwin Kalvelagen
GAMS Development Corp., http://www.gams.com
, http://www.gams.com/~erwin
----------------------------------------------------------------



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default how to get hwnd from application object?

Erwin,

In Excel 2002 and later, you can get the hWnd property directly
from the Application object. E.g.,

Dim XLHWnd As Long
XLHWnd = Application.Hwnd

In earlier versions, you need to use FindWindow on "XLMAIN".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Erwin Kalvelagen" wrote in message
...

Hi:

I am using Excel from another app using COM/OLE. I need
to bring the Excel window to the foreground. Is there any way
to the hWnd from the Application object? Now I use the
FindWindow API call to find the Excel window
but that is not foolproof.

Thanks, Erwin


---------------------------------------------------------------

-
Erwin Kalvelagen
GAMS Development Corp., http://www.gams.com
, http://www.gams.com/~erwin
---------------------------------------------------------------

-





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how to get hwnd from application object?


Ah, great, that explains it. I am running good old Excel 2000.
Thanks for the explanation!

--
----------------------------------------------------------------
Erwin Kalvelagen
GAMS Development Corp., http://www.gams.com
, http://www.gams.com/~erwin
----------------------------------------------------------------


"Chip Pearson" wrote in message ...
Erwin,

In Excel 2002 and later, you can get the hWnd property directly
from the Application object. E.g.,

Dim XLHWnd As Long
XLHWnd = Application.Hwnd

In earlier versions, you need to use FindWindow on "XLMAIN".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Erwin Kalvelagen" wrote in message
...

Hi:

I am using Excel from another app using COM/OLE. I need
to bring the Excel window to the foreground. Is there any way
to the hWnd from the Application object? Now I use the
FindWindow API call to find the Excel window
but that is not foolproof.

Thanks, Erwin


---------------------------------------------------------------

-
Erwin Kalvelagen
GAMS Development Corp., http://www.gams.com
, http://www.gams.com/~erwin
---------------------------------------------------------------

-







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application/Object defined error? Myles Excel Discussion (Misc queries) 0 March 27th 09 07:48 PM
cannot start the source application for this object Crystal Excel Discussion (Misc queries) 0 February 13th 08 03:21 PM
CANNOT START THE SOURCE APPLICATION FOR THIS OBJECT WORD USER New Users to Excel 0 August 21st 06 04:55 PM
Cannot start the source application for this object Excel General Questions Excel Discussion (Misc queries) 0 February 2nd 05 07:05 PM
"Excel.Application" Object Model Shaker Charts and Charting in Excel 2 January 9th 05 10:24 AM


All times are GMT +1. The time now is 12:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"