4 Replies Latest reply: May 8, 2011 2:31 PM by Erich Shiino RSS

    Run a Macro after The Clear Button is clicked

    Josue Andrade

      Hi,

       

      In my qvw I have some selections that I realy need to maintain some consistences. However, when I click on the Clear Button, All selection

      is gone (including the Locked ones).

       

      Is there a way to run a macro after I clicked the Clear Button ? Or some other way to force running a macro after that ?

       

      Thanks!!

        • Run a Macro after The Clear Button is clicked
          Oleg Troyansky

          You can trigger an Action (including a macro) off "OnAnySelect" event - it's defined in Document Properties, "Triggers". I'm not totally positive, but I think "OnAnySelect" should get triggered when all selections are cleared.

           

          Within the macro, you can then validate what selections are made, and build your logic accordingly.

          • Run a Macro after The Clear Button is clicked
            Erich Shiino

            Oleg's approach will give you more possibilities. However, depending on you need you could set a clear state to return the selection to a previously determined setting when the user click on clear (instead of clearing everything).

            Make your selections, go to the clear button and open a small combo box on the right.

            Click set clear state.

            After this, the clear button go back to this selection.

             

            Rgds,

              • Run a Macro after The Clear Button is clicked
                Josue Andrade

                The OnAny Select appears to apply when you make any selection, not only with the Clear Button.

                I liked the Idea of the Clear State, but there's a problem: it doesn't save the values of the variables. Any idea how to solve that ?

                Thanks !!!

                  • Re: Run a Macro after The Clear Button is clicked
                    Erich Shiino

                    Hi,

                    I was able to run a macro when all the selections were cleared.

                    First, I created a variable vClear = isnull(GetCurrentSelections())

                    It can be true or false.

                     

                    After that, I include a OnChange trigger on this variable to call a macro (message)

                    with the following code:

                     

                    sub message

                    set x = ActiveDocument.GetCurrentSelections

                    s = x.Selections

                    v = x.VarId

                     

                    'msgbox ActiveDocument.ActiveSheet.GetCurrentSelections.count

                    if ubound(s)<0 then

                    msgbox ("You cleared all the selections")

                     

                    end if

                    end sub

                     

                    Instead of the msgbox you could have any code.

                     

                    I couldn't find a way to dfferenciate a clear button from a one-by-one clear field.

                     

                    I include my sample app here

                     

                    Hope it helps,

                     

                    Erich