12 Replies Latest reply on Jun 18, 2010 8:53 AM by Pat R O'Neill

    (CS3)(VB) Selecting a Header Row - How to?

      myRows.item(1)
      selects the first body row.

      How do I select the header row and footer row

      Bob
        • 1. Re: (CS3)(VB) Selecting a Header Row - How to?
          Glen_Bal Level 1
          This is what i think:
          For the header row:
          myRows.item(0)

          For the footer row:
          myRows.item(myRows.count())

          That is ofcourse if the header and footer is just one row.

          Greetz,
          Glen
          • 2. Re: (CS3)(VB) Selecting a Header Row - How to?
            Level 1
            Hi Glen,

            myRows.item(0) returns an error

            myRows.item(1) always returns the first Body Row even if you have several Header Rows.

            Bob
            • 3. Re: (CS3)(VB) Selecting a Header Row - How to?
              Level 1
              What code are you using to set the value of myRows?

              Dave
              • 4. Re: (CS3)(VB) Selecting a Header Row - How to?
                Level 1
                Hi Dave:
                Abbreviated code (I use the PowerBasic Compiler):

                OBJECT CALL myTextFrame.Tables.Add TO myTable
                vtemp = bodycount
                OBJECT SET myTable.BodyRowCount = vtemp
                vtemp = headercount
                OBJECT SET myTable.HeaderRowCount = vtemp
                vtemp = footercount
                OBJECT SET myTable.FooterRowCount = vtemp
                :
                : setup columns
                :
                vtemp = tablestyle
                OBJECT SET myTable.AppliedTableStyle = vtemp
                ---------------------------
                To access the rows:

                OBJECT GET myTable.Rows TO myRows
                vtemp = currentrow
                OBJECT GET myRows.Item(vtemp) TO myRow
                OBJECT GET myRow.Cells TO myCells
                vtemp = currentcellposn
                OBJECT GET myCells.item(vtemp) TO myCell
                --------------------------------------------

                The Headers & Footers are displayed correctly but when I read any of the myRows data the headers & footers do not appear in any of the counts and MyRows.item(1) (or any other count) always returns a body row and any text is correctly placed in the body of the table.

                Bob
                • 5. Re: (CS3)(VB) Selecting a Header Row - How to?
                  Level 1
                  I've been doing a fair bit of table scripting in recent days and I've not had this problem. But then, I've been using JavaScript. The header rows are the first rows in the table and the footer rows are the last.

                  I can't see anything wrong with your code, but it is an unfamiliar language to me.

                  Dave
                  • 6. Re: (CS3)(VB) Selecting a Header Row - How to?
                    Level 1
                    Hi Dave,

                    Could you possibly post a sample code creating a simple table with a header and footer line and inserting a word into a header cell and footer cell.

                    I don't know javascript but I should be able to interpret it.

                    Does Javascript use the same tlb file as Visual Basic if not, where can I find a copy?

                    Thanks, Bob
                    • 7. Re: (CS3)(VB) Selecting a Header Row - How to?
                      Level 1
                      Hi Dave,

                      Since writing the above I have rewritten my code in VB6 - the effect is the same - the text appears in Row 2.

                      --------------------------------------
                      Set myIndesign = CreateObject("InDesign.Application.CS3")
                      myIndesign.Open (masterpagefile)
                      Set myWindow = myIndesign.ActiveWindow
                      Set mySpread = myWindow.ActiveSpread
                      Set myPage = mySpread.Pages.Item(1)
                      Set myDocument = myIndesign.ActiveDocument
                      mastercount = myDocument.MasterSpreads.Count
                      Set myMaster = myDocument.MasterSpreads.Item(1)
                      Set myTextFrame = myPage.TextFrames.Item(1)
                      Set myTable = myTextFrame.Tables.Add
                      myTable.BodyRowCount = 3
                      myTable.HeaderRowCount = 1
                      myTable.FooterRowCount = 1
                      myTable.ColumnCount = 3

                      Set myRows = myTable.Rows
                      Set myRow = myRows.Item(1)
                      Set myCells = myRow.Cells
                      Set myCell = myCells.Item(1)

                      myCell.InsertionPoints.LastItem.Contents = "Row1,Cell1"
                      -------------------------------------

                      So how do I get to the header/footer rows?
                      --------------------------------------
                      Found workaround:

                      set header & footer row counts to 0 and increase the body row count by 2.

                      Set the first and last rows to Header & Footer respectively.


                      Bob
                      • 8. Re: (CS3)(VB) Selecting a Header Row - How to?
                        Level 1
                        I derived this from your code.
                        app.documents.add();
                        
                        myWindow = app.activeWindow
                        mySpread = myWindow.activeSpread
                        myPage = mySpread.pages.item(0)
                        myDocument = app.activeDocument
                        mastercount = myDocument.masterSpreads.length
                        myMaster = myDocument.masterSpreads.item(0)
                        myTextFrame = myPage.textFrames.add({geometricBounds:myPage.bounds});
                        myTable = myTextFrame.tables.add();
                        myTable.bodyRowCount = 3
                        myTable.headerRowCount = 1
                        myTable.footerRowCount = 1
                        myTable.columnCount = 3

                        myRows = myTable.rows
                        myRow = myRows.item(0)
                        myCells = myRow.cells
                        myCell = myCells.item(0)

                        myCell.insertionPoints[-1].contents = "Row1,Cell1"
                        It puts the text into the first cell of the header row.

                        Dave
                        • 9. Re: (CS3)(VB) Selecting a Header Row - How to?
                          Level 1
                          Hi Dave,

                          Unfortunately I get an error in both my Basics when I try to use

                          myRow = myRows.item(0) in fact ".item(0)" is not a valid item value in any statement.

                          Possibly there is an error in the COM interface - is this something I should report and ifso to whom?

                          Many thanks for trying to help me (my work around solves the problem for the moment)

                          Bob
                          • 10. Re: (CS3)(VB) Selecting a Header Row - How to?
                            Level 1
                            Indeed, Item(1) in Basic should give the same result as item(0) in JavaScript.

                            I don't know enough about Basic to make much in the way of sensible suggestions. I was hoping a Basic person would drop by with some help.

                            Dave
                            • 11. Re: (CS3)(VB) Selecting a Header Row - How to?
                              [Jongware] Most Valuable Participant
                              Wasn't there something with "Option Base" 0 or 1? That changes the starting point for arrays between Basic style (1) and JavaScript style (0).
                              • 12. Re: (CS3)(VB) Selecting a Header Row - How to?
                                Pat R O'Neill

                                Arrays in VB start with 0.

                                Its Collections in VB that (iirc) start with 1.