4 Replies Latest reply on Apr 14, 2008 11:14 AM by (Dmitry1776)

    Why doesnt applies table style?

      Give, pls a hint (again ;))
      I plan to format table entirely (table style, all cells style, para body style, para header style and cell header style)

      I stared with:
      Set MyInd = CreateObject("InDesign.Application.CS3")
      Set myDoc = MyInd.ActiveDocument
      Set myPage = myDoc.Pages.Item(1)
      MyInd.Paste '(get clipboard from word-table)
      Set myStory = myDoc.Stories.Item(1)
      Set myParagraph = myStory.Paragraphs.Item(1)
      Set myTable = myParagraph.Tables.Item(1)
      On Error Resume Next 'for debugging purpose
      myTable.Rows.Item(1).RowType = idRowTypes.idHeaderRow
      On Error GoTo 0

      'myTable.AppliedTableStyle = "Table Style Body"
      i work, but don't overrides

      'myTable.AppliedCellStyle = "Table Style Body" '''the same

      myTable.ApplyStyle "Table Style Body", True
      i override, but "OBJECT DOESNT support!"

      myTable.ApplyStyle "Cell Style Body", True 'the same

      How to apply table style to whole table? (how to script correctly?)

        • 1. Re: Why doesnt applies table style?
          Level 1
          you need to call:

          with myTable
          call .cells.itembyrange(.cells.item(1),.cells.item(-1)).item(-1).clearcellstyleoverrides
          call .ClearTableStyleOverrides()
          end with

          and not:

          myTable.ApplyStyle "Table Style Body", True


          Call myTable.ApplyStyle("Table Style Body", True)


          • 2. Re: Why doesnt applies table style?
            Level 1
            Ok. It worked, thanks.
            But i'd like to format also table contents by applying "Table body" to whole table and now at line:

            b Call myTable.ApplyParagraphStyle("Table body", True)

            again says: "Object doesn't support property or method" :(
            • 3. Re: Why doesnt applies table style?
              Level 1
              I wrote like this:

              kk = myTable.Columns.Count
              With myTable
              Call .Cells.ItemByRange(.Cells.Item(1), .Cells.Item(-1)).Item(-1).ClearCellStyleOverrides
              Call .ClearTableStyleOverrides
              Set mySel = .Cells.ItemByRange(.Cells.Item(1), .Cells.Item(-1)).Item(-1) 'for all table
              Set mySelH = .Cells.ItemByRange(.Cells.Item(1), .Cells.Item(kk)).Item(-1) 'for only header
              End With

              myTable.AppliedTableStyle = "Table Style Body"
              mySel.AppliedCellStyle = "Cell Style Body"
              mySelH.AppliedCellStyle.AppliedParagraphStyle = "Table body"
              mySelH.AppliedCellStyle = "Cell Style Head"
              mySelH.AppliedCellStyle.AppliedParagraphStyle = "Table Head"

              So we can apply parastyles only for object "cell", not for "table"?
              So we must have specified range of cells for working with?

              • 4. Re: Why doesnt applies table style?
                Level 1
                you can't do this that way :)
                this can by done this way only from JS using EveryItem function
                in VB you need to iterate all cells in all columns and apply ParaStyle

                you can play with something like this:


                but this don't work for me :(