ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check if within Function Wizard (https://www.excelbanter.com/excel-programming/312968-check-if-within-function-wizard.html)

patochem

Check if within Function Wizard
 
If you have a User Defined Function that requires a long time to
evaluate, the use of the Function Wizard could be really annoying as
it recalculates at every key stroke.

A way to avoid it is to check if the following function at the
beginning of each of your UDF.

------------------------------------------------------------
Function InsideWizard() As Boolean
Dim ActiveWndHandle As Long
Dim ParentWndHandle As Long
Dim ActiveWndProcessId As Long
Dim ParentWndProcessId As Long
Dim Result As Long

ActiveWndHandle = GetActiveWindow()
If ActiveWndHandle = 0 Then Exit Function
ParentWndHandle = GetParent(ActiveWndHandle)
If ParentWndHandle = 0 Then
InsideWizard = False
Exit Function
End If

Result = GetWindowThreadProcessId(ActiveWndHandle,
ActiveWndProcessId)
Result = GetWindowThreadProcessId(ParentWndHandle,
ParentWndProcessId)
If ParentWndProcessId = ActiveWndProcessId Then InsideWizard =
True Else InsideWizard = False
End Function
---------------------------------------------------------------


All times are GMT +1. The time now is 01:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com