4 Replies Latest reply on Aug 29, 2014 6:30 AM by Russ Ward

    Change Color in CellOverrideShading


      Hi all,


      I tried to change the color in CellOverrideShading but I didn't get it.

      My attempts were the following:

      First I tried to get the index of the color property via GetPropIndex:

      var testProp = cell.CellOverrideShading.GetProps();

      var testPropIndex = GetPropIndex(testProp, Constants.FP_Color);

      But the result is "-4", so it seems that CellOverrideShading has no FP_Color property.


      Second: I tried to change the color via the PropVal object:

           testProp[1].propVal.sval = 'Olive';

      When I print the properties to the Console the color name seems to be updated to 'Olive'

      for (var i=0; i <testProp.length; i++)


                  propText = propText + ' \n' + i + ': ' + testProp[i].propIdent.name + ' - ' + testProp[i].propIdent.num + ' - ' + testProp[i].propVal.sval;


      1:  - 20 - Olive


      Then I assin the properties to the cell.



      But the color in the Frame document remains unchanged. When I print the color name to the Console [Console('FARBE: ' + cell.CellOverrideShading.Name);]

      I still receive FARBE: Königsblau

      What's my mistake? Any ideas?


      Yours Wolfgang

        • 1. Re: Change Color in CellOverrideShading
          RussDWard Level 1

          Hi Wolfgang,


          I think you have a misunderstanding of GetProps() and SetProps(), which is the foundation of your trouble. When you do this:


          var testProp = cell.CellOverrideShading.GetProps()


          ... you are getting the properties of the color object assigned to the CellOverrideShading property, not the cell. And, in this case, the CellOverrideShading property just happens to be an object, otherwise the GetProps() method would not be valid at all. Anyway, a color object has no FP_Color property, hence the reason that you can't find it in the PropVals array.


          You could do it with the cell properties directly, maybe something like this (note - I didn't test this!):


          var testProps = cell.GetProps();

          var testPropIndex = GetPropIndex(testProps, Constants.FP_CellOverrideShading);


          ...then more code to manipulate the array and reset the properties. However, I would recommend this direct approach instead (again, I didn't test this!):


          var colorObj = doc.GetNamedColor("Olive");

          if(colorObj.ObjectValid()) cell.CellOverrideShading = colorObj;


          I hope this helps some.



          • 2. Re: Change Color in CellOverrideShading

            Hi Russ, I'm trying to achieve the same thing but am having a little trouble.




            // Get the table cell that contains the paragraph. 

            var cell = pgf.InTextObj; (alert returns a cell  object)

            cell.CellUseOverrideShading = true ;

            cell.CellUseOverrideFill = true ;

            cell.CellOverrideFill = 15 ;

            var colorObj = doc.GetNamedColor("Red");

            cell.CellOverrideShading = colorObj;



            Expect to see red cells in my table but am not, any idea what I'm missing?





            • 3. Re: Re: Change Color in CellOverrideShading
              frameexpert Level 4

              Hi Tracey, This works for me. I used 0 instead of 15. Make sure you refresh the screen after you run the code.


              #target framemaker
              var doc = app.ActiveDoc;
              var pgf = doc.TextSelection.beg.obj;
              var cell = pgf.InTextObj;
              // Get the Red color object.
              var color = doc.GetNamedColor ("Red");
              // Set the cell's properties to 100% Red.
              cell.CellOverrideShading = color;
              cell.CellUseOverrideShading = true;
              cell.CellOverrideFill = 0;
              cell.CellUseOverrideFill = true;



              • 4. Re: Re: Re: Change Color in CellOverrideShading
                Russ Ward Level 4

                Hi Tracey,


                Rick is correct. The CellOverrideFill property indicates the fill pattern and it is specified as a constant from 0-15, where 15 is effectively no pattern. Hence why you were seeing nothing happen. Here is a figure from the FDK manual that describes the constants, with a convenient reference to the FM GUI: