2 Replies Latest reply on Feb 29, 2012 2:35 PM by BigGunN

    how to apply character style to table cell

    BigGunN Level 1

      I am sure this is basic, but I cannot find any references on how to do it and my attempts have all failed.  I am using VB and CS5.5

       

      Basically what I am trying to do is select a table cell, and apply a character style to it, like so...

       

      set myCharacterStyle = myDocument.CharacterStyles.Add

      myCharacterStyle.Name = "TH2"

      myTable2.Cells.Item(1).appliedCharacterStyle = "TH2"

       

      with this code, I am getting a "Object doesn't support this property or method.  myTable2.Cells.Item(...).appliedCharacterStyle"

       

      I have tried several other versions without success.

       

      Can anyone tell me what the proper syntax for applying a character style to the text in a table cell would be, or if this is even the right way to go about this?

       

      Do I need to select the text in the cell rather than the cell itself, and if so, how do you do that?

       

      thanks

        • 1. Re: how to apply character style to table cell
          TᴀW Adobe Community Professional & MVP

          You don't need to actually select the text in the cell, but you do need

          to target it rather than the cell. It's true that in the UI you can

          select the cell and apply a char style, but not with a script. So in

          Javascript it's:

           

          myCell.texts.item(0).appliedCharacterStyle =

          app.activeDocument.characterStyles.itemByName("MyCharStyleName")

           

          It must be something similar in VB as well.

           

          Obviously you can target the text in many different ways:

          myCell.characters.everyItem() or myCell.paragraphs.everyItem() etc. etc.

          but I think that texts is the most basic of the lot.

           

          Ariel

          • 2. Re: how to apply character style to table cell
            BigGunN Level 1

            thank you ariel.  that worked great.

             

             

            set myCell = myTable2.Cells.Item(1)

            myCell.texts.item(1).appliedCharacterStyle = "TH2"