4 Replies Latest reply on Jun 11, 2008 10:26 AM by (Daniel_Grossi)

    [CS3 JS] Find/Change Object Problem

      app.changeObjectPreferences = NothingEnum.nothing does not seem to clear the change object preferences for me.

      app.findObjectPreferences = NothingEnum.nothing works as expected, as do both app.findTextPreferences = NothingEnum.nothing and app.changeTextPreferences = NothingEnum.nothing.

      Does anyone else use the new Find/Change Object?
        • 1. Re: [CS3 JS] Find/Change Object Problem
          Level 1
          I wonder if anyone can reproduce this problem. The following code, for me, performs the changeObject() and clears the findObjectPreferences, but fails to clear the changeObjectPreferences.

          app.findObjectPreferences = NothingEnum.nothing;
          app.changeObjectPreferences = NothingEnum.nothing;
          app.findObjectPreferences.overprintStroke = true;
          app.changeObjectPreferences.overprintStroke = false;
          app.activeDocument.changeObject();
          app.findObjectPreferences = NothingEnum.nothing;
          app.changeObjectPreferences = NothingEnum.nothing;

          I don't know whether I'm missing something simple or if this is, in fact, a bug.
          • 2. Re: [CS3 JS] Find/Change Object Problem
            Level 1
            Jeff,

            I think you've (re)found a bug that was discussed here sometime in the last couple of weeks or so.

            Dave
            • 4. Re: [CS3 JS] Find/Change Object Problem
              Hello. I'm new here but it seems to be the only place where I can post this question to.
              I'm working in a C# application that uses InDesign CS3 scripting. I'm trying to create an index automatically from a tabbed list of words in a text file.
              As C# is a strongly typed language, I have to cast all objects to the right type. I'm having problems when I try to add the page numbers to the created index entries using the following code (I've used the CreateIndexEntry.jsx scrip as a starting point).

              //Find all occurrences of the word or set of words (the topic name)

              ...
              ((InDesign.FindTextPreference) app.FindTextPreferences).FindWhat = topic.Name;

              ...

              InDesign.Objects foundTexts = doc.FindText(System.Reflection.Missing.Value);

              It's supposed to be an Array of Text objects (InDesign.Text) but when I try to cast each object using this

              //Code is forced because I've tried everything here

              //Loop through each finding and add page numbers to topic

              IEnumerator textEnum = foundTexts.GetEnumerator();
              while (textEnum.MoveNext())
              {
              object text = textEnum.Current;
              topic.PageReferences.Add((InDesign.Text)text, InDesign.idPageReferenceType.idCurrentPage, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
              }
              }

              I got the following exception (translated).

              text is not an InDesign.Text object (Interfaces doesn't match)

              So the question is what object type should I use to cast each object resulting by calling the Document's FindText method.

              Every suggestion will ve very welcome.
              Thank You very much.