Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all!
I want a macro to be run when a certain condition is fulfilled.
Like: If "Count(DISTINCT Field1)<10" then run the macro.
Is there anyway to do this? Can't see how this can be done by using triggers/actions.
Br
Peter
Hi Peter,
Go to
Document Properties Tab--> Triggers Tab--> Document Event Trigger --> Click On Any Select --> Add Actions --> External --> Run Macro -->
If(Count(Distinct Field1)<10,'Macro')
May be this might helps you.
Regards,
Satish.A
Maybe set a variable to =Count(DISTINCT Field1)
and then use the Variable Event OnChange action?
Hello,
Use this code,
Button ->action -> External -> Run macro -> in macro name give the below code. "Macro" is the name of the Macro Code
=If(Count(DISTINCT date)<10,'Macro')
My macro code is:
Sub Macro
ActiveDocument.GetSheetObject("LB05").SelectAll
End Sub
Cheers!
Hope it helps you.
The Variable Event OnChange action mean that you have to edit the variable expression to execute the action. It doesn't run due to the change in the calculated result in the variable (Count DISTINCT). So that's not the solution, unless I missunderstood.
Thanks
Ok, but this mean you still have to click the button to execute the macro. What I'm looking for is execute a macro whenever the number of distinct values in a certain field is less than 10, due to some selections made in other fields, without having to click a button.
Thanks
Hi Peter,
Go to
Document Properties Tab--> Triggers Tab--> Document Event Trigger --> Click On Any Select --> Add Actions --> External --> Run Macro -->
If(Count(Distinct Field1)<10,'Macro')
May be this might helps you.
Regards,
Satish.A
Ok take one global variable with name vCount and give expression as =Count(DISTINCT Field1). Now create one empty varible with name vCheck.
- Document properties -> Triggers Tab -> Document event triggers -> OnAnySelect ->Actions -> Add -> External -> RunMacro -> macro name Assign
And paste in edit module below code:
Sub Assign
Set vCount=ActiveDocument.Variables("vCount")
Set vCheck=ActiveDocument.Variables("vCheck")
vCheck.SetContent vCount.GetContent.String,true
If vCheck.GetContent.String < 2 then
Call(RunMacroCode)
End If
End Sub
Sub RunMacroCode
' Here give ur code
End Sub
Cheers!
Hope it helps you.
Thank you very much!
Regards Peter
Edit: Just realised this won't work when you toggle Back and Forward between a selection with less and more than ten values.
However, thanks anyway.
Edit again: Won't work with bookmarks either.
And worst of all, the macro (SQL connection) won't work at all in AJAX