5 Replies Latest reply: Apr 27, 2009 1:06 AM by Jay Jakosky RSS


      Hi Everyone,

      I need a help on macro.

      I have two tabs in one report. I have selection boxes on both tabs. When I move from first tab to second tab, I need to clear the selection boxes.I did that using the below macro,

      sub Clear
      end sub

      Now, when I move back to first tab, I need the same selection which I selected previously (prior to moving to second tab). could someone help me with the macro.

      Ex: I clear the selection made on "F1", when I move to 2nd tab. I need the selection made on "F1" to be present, when moved to 1st tab.

      Please see the attachment


        • Macro

          Hello Pascal,

          Using a public variable should do the trick:


          Public Selection

          sub AwayFromTab1
          set Selection = ActiveDocument.Fields("F1").GetSelectedValues
          end sub

          sub BackToTab1
          set f1 = ActiveDocument.Fields("F1")
          f1.SelectValues Selection
          end sub

          I hope this helped you out.


          • Macro


            Public selarr()

            Public fldarr()

            Public valcount


            sub LeaveTab


            set vals=ActiveDocument.Fields("$Field").GetPossibleValues

            Redim selarr(valcount)

            Redim fldarr(valcount)

            for i=0 to valcount-1


            set selarr(i)=ActiveDocument.GetField(vals.Item(i).text).GetSelectedValues


            ActiveDocument.clearAll false

            end sub



            sub ReturnToTab

            for i=0 to valcount-1

            ActiveDocument.GetField(fldarr(i)).SelectValues selarr(i)


            end sub