Usage of Hwnd property

Add-in Express™ Support Service
That's what is more important than anything else

Usage of Hwnd property
 
Kiru Marimuthu




Posts: 28
Joined: 2017-07-20
Hi

In Excel 2013/2016 I am trying to identify each instance of excel uniquely in the CustomTaskPane event ADXAfterTaskPaneShow. So I tried to make use of Hwnd property in the CustomTaskPane like this.

 dynamic excelApp = ExcelAppObj as Microsoft.Office.Interop.Excel._Application;
 var uniqueId = excelApp.Hwnd;


When I open two instances of excel quickly I can see the same Hwnd value for both. But I have a different Hwnd when I use this
dynamic excelWindow = WindowObj as Microsoft.Office.Interop.Excel.Window;
var excelApp = excelWindow.Application as Microsoft.Office.Interop.Excel._Application;
var uniqueId = excelApp.Hwnd;


Please recommend which one we should use.
Posted 16 May, 2018 08:28:04 Top
Andrei Smolin


Add-in Express team


Posts: 15108
Joined: 2006-05-11
Hello Kiru,

I assume you try to identify Excel windows. If so, you do this using Window.Hwnd. Also, if this info is required, you can get the Excel.Window object representing the window in which the ADXExcelTaskPane is shown via ADXExcelTaskPane.WindowObj.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 16 May, 2018 10:06:53 Top