Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting excel process id
Hi,
I am working on excel automation. I want the get the handle and process id for the excel process. Following is the way I am creating the excel application. Excel.Application xlApp = new Excel.Application(); There is one way of getting the handle (hwnd) to the excel process by making the application visible, then setting a caption and getting the handle using FindWindow method. But I don't want to make the application visible. So is there any other way of doing it? I am using Excel 2000, C# 2.0. Regards, Asim. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting excel process id
The Application object has an HWnd property, but I don't recall if it is
present in Excel 2000. You can use the FindWindow API call to find the HWnd. In VB, this would be Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Function GetXLHwnd() As Long GetXLHwnd = FindWindow("XLMain", Application.Caption) End Function If you can be sure that you have only one instance of Excel running, you can substitute vbNullString for Application.Caption. The Application need not be visible for this to work. -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "Asim" wrote in message ... Hi, I am working on excel automation. I want the get the handle and process id for the excel process. Following is the way I am creating the excel application. Excel.Application xlApp = new Excel.Application(); There is one way of getting the handle (hwnd) to the excel process by making the application visible, then setting a caption and getting the handle using FindWindow method. But I don't want to make the application visible. So is there any other way of doing it? I am using Excel 2000, C# 2.0. Regards, Asim. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting excel process id
Hi,
Thanks a lot. It works now. Regards, Asim. "Chip Pearson" wrote: The Application object has an HWnd property, but I don't recall if it is present in Excel 2000. You can use the FindWindow API call to find the HWnd. In VB, this would be Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Function GetXLHwnd() As Long GetXLHwnd = FindWindow("XLMain", Application.Caption) End Function If you can be sure that you have only one instance of Excel running, you can substitute vbNullString for Application.Caption. The Application need not be visible for this to work. -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "Asim" wrote in message ... Hi, I am working on excel automation. I want the get the handle and process id for the excel process. Following is the way I am creating the excel application. Excel.Application xlApp = new Excel.Application(); There is one way of getting the handle (hwnd) to the excel process by making the application visible, then setting a caption and getting the handle using FindWindow method. But I don't want to make the application visible. So is there any other way of doing it? I am using Excel 2000, C# 2.0. Regards, Asim. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using excel to process QIF file | Excel Discussion (Misc queries) | |||
Excel Process Doesn't End :-( | Excel Programming | |||
Kill Excel Process | Excel Programming | |||
How to count process running time ( process not finished) | Excel Programming | |||
How to count process running time ( process not finished) | Excel Programming |