In addition to what Andrew provided here, there is yet another way, which is probably not that good but can be taken into account:
Using the viewcursor you can go from the beginning to the end of the document regularly checking if the property TextTable of the viewcursor is void (IsEmpty(cur.TextTable)) .
Nevertheless the enumeration way is the more reliable one.

Do note, that right now in the 680 line (2.0 beta) thisComponent is broken, so use Stardesktop.getCurrentComponent() instead and make sure you run the macro from the menu and not from the Basic IDE.

2005/6/15, Andrew Douglas Pitonyak <[EMAIL PROTECTED]>:
Martin Thoma wrote:

>Hello! I have a text-document which contains some tables:
>
>Table1 (Named "MyTable")
>Table2 (Named "My 2nd Table")
>
>I copy+paste (executeDispatch) Table1 some times into the document:
>Table1 (Named "MyTable")
>NewTable (Named "Table 4")
>NewTable (Named "Table 5")
>NewTable (Named "Table 6")
>NewTable (Named "Table 7")
>Table2 (Named "My 2nd Table")
>
>What I need is to access the NewTables in the right order.
>
>I tried to use getTextTables, because I thought it returns the tables in the
>order they are in to document, but it gives:
>
>Table1 (Named "MyTable")
>Table2 (Named "My 2nd Table")
>NewTable (Named "Table 4")
>NewTable (Named "Table 5")
>NewTable (Named "Table 6")
>NewTable (Named "Table 7")
>
>I coulnd't rely on the table-name, because I don't know which tables are
>already inside the document.
>
>My idea now is to store all table-names before the copy+paste, use
>getTextTables and compare the names with the tables-names I stored - but I
>have to be sure that the first table I get will be the first I inserted
>("Table 4") and not some other of the new tables (like "Table 6"). Will this
>ALWAYS be the case?
>
>Regards
>
>Martin
>
>
If I understand your problem correctly, you want to enumerate the text
tables in the order that they are contained in the document. Is this
correct? If so, remember that TextTables are stored as a paragraph, so
you will find them while enumerating paragraphs.

Sub EnumerateTextTablesInOrder
  Dim oEnum
  Dim s$
  Dim oPar

  oEnum = ThisComponent.getText().createEnumeration()
  Do While oEnum.hasMoreElements()
    oPar = oEnum.nextElement()
    If oPar.supportsService("com.sun.star.text.TextTable") Then
      s = s & oPar.getName () & CHR$(10)
    End If
  Loop
  MsgBox s, 0, "Text Tables"
End Sub

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw
My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm
Free Info:  http://www.pitonyak.org/oo.php


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Best Regards
Christian Junker

Reply via email to