Check if within Function Wizard

  • Thread starter Thread starter patochem
  • Start date Start date
P

patochem

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
---------------------------------------------------------------
 
Here is a one-line method first suggested by Axel König, which works well

If (Not Application.CommandBars("Standard").Controls(1).Enabled) Then Exit
Function

regards
Charles
______________________
Decision Models
FastExcel 2.1 now available
www.DecisionModels.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top