Export (0) Print
Expand All
Expand Minimize

_Application.HinstancePtr property

Gets a handle to the instance of Microsoft Excel 2010 represented by the specified _Application object.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Object HinstancePtr { get; }

Property value

Type: System.Object
A handle to the instance of Microsoft Excel 2010 represented by the specified _Application object.

Read-only Variant.

This property returns a correct handle in both the 32- and 64-bit versions of Excel. It extends the functionality of the Hinstance property of the _Application object, which only works correctly in the 32-bit version of Excel.

The ideal data type to use with this property is the LongPtr data type. Assigning the value returned by this property to a LongPtr variable will work as expected in both 32- and 64-bit versions of Excel. The property is defined as Variant for internal implementation reasons. However, it always returns a 32-bit value on 32-bit systems and a 64-bit value on 64-bit systems.

This property only works starting with Excel 2010, and is only required with the 64-bit version of Excel. If you must write code that will also work with earlier versions of Excel, in order to avoid compilation errors, read this property under an #if Win64 conditional compilation directive, and use the Hinstance property under the #else directive.

NoteNote

This property works fine in both 32- and 64-bit environments starting with Excel 2010. Therefore, if your code is intended to be used only with Excel 2010 or later, either 32- or 64-bit, it can read this property without conditional compilation.

Community Additions

ADD
Show:
© 2014 Microsoft