5 Replies Latest reply: Nov 20, 2009 8:21 PM by Neil Miller RSS

    Why does "Field.ToggleSelect" work when "Field.SelectValues" fails?

    ChristianKnott

      I have some very simple data and code (culled from a larger application) where I'm trying to select multiple values of a field in a macro.

      Here's the sample version:

       


      LOAD * INLINE [
      release, revisions
      20.5, 140
      20.6, 132
      20.7, 129
      20.8, 145
      ];


      and two code snippets:

       


      rem Using SelectValues, doesn't work
      set releaseField = ActiveDocument.Fields("release")
      set fieldValues = releaseField.GetNoValues

      fieldValues.Add
      fieldValues(0).Text = "20.5"
      fieldValues.Add
      fieldValues(0).Text = "20.6"

      releaseField.SelectValues(fieldValues)
      rem Using ToggleSelect *does* work
      ActiveDocument.Fields("release").Select("20.5")
      ActiveDocument.Fields("release").ToggleSelect("20.6")


      ToggleSelect works to allow me to select multiple values of the field, but the seemingly more flexible and powerful SelectValues fails (returns false).

      What subtlety about SelectValues am I missing? In other words, why is SelectValues failing?

      This is using v8.5.

      Thanks!