It works! Thank you for the help! B.
----- Message d'origine ---- De : Andrew Douglas Pitonyak <[EMAIL PROTECTED]> À : [email protected] Envoyé le : Dimanche, 1 Avril 2007, 7h40mn 29s Objet : Re: [users] Bookmarks in OOBasic Boris Ratak wrote: > Hi, > > I'm using OOBasic to access bookmarks in Writer and Word documents. It's > pretty easy to write down some text in them, but is it possible to access a > table located in a bookmark? I know this is possible in VBA, but I've tried > to do it in OOBasic, without success. > Here's what I try : > myBk = oDoc.Bookmarks.getByName("someBookmark") > myTable = myBk.Anchor.TextTables(1) > OR > myTable = myBk.TextTables(1) > > > I know I could access the Table directly by giving it a name, but as I handle > Word documents, the name of the table is lost. > > Any idea someone? > > Thx > > B. > No, you can not directly access the text table inside of a bookmark. Unfortunately, you must enumerate the contained text and look for the contained text tables. I do not have time to demonstrate a clean solution, but: Sub FindFirstTableInBookmark Dim oMark Dim oEnum 'Enumeration of text sections. Dim oSect Dim oParEnum Dim oPar Dim oField 'Enumerated text field. Dim s$ 'Generic string variable. Dim n% 'Count the number of text fields. Dim sPrompt$ Dim i% Dim sRefName Dim oSel Dim oSels Dim oLastBookMarkName$ Dim oCurs Dim oText oMark = ThisComponent.Bookmarks.getByName("First") oParEnum = oMark.getAnchor().createEnumeration() Do While oParEnum.hasMoreElements() oPar = oParEnum.nextElement() If oPar.supportsService("com.sun.star.text.Paragraph") Then 'oEnum = oPar.createEnumeration() 'Do While oEnum.hasMoreElements() ' oSect = oEnum.nextElement() ' If NOT IsNull(oSect.Bookmark) Then ' REM Bookmark ' If oLastBookMarkName <> oSect.Bookmark.getName() Then ' oLastBookMarkName = oSect.Bookmark.getName() ' s = s & oSect.Bookmark.getName() & " : " & oSect.Bookmark.getAnchor().getString() & CHR$(10) ' n = n + 1 ' End If ' End If 'Loop ElseIf oPar.supportsService("com.sun.star.text.TextTable") Then n = n + 1 s = s & "Table: " & oPar.getName() End If Loop If n > 0 Then MsgBox s s = "" : n = 0 End If End Sub -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt My Book: http://www.hentzenwerke.com/catalog/oome.htm Info: http://www.pitonyak.org/oo.php See Also: http://documentation.openoffice.org/HOW_TO/index.html --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ___________________________________________________________________________ Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses http://fr.answers.yahoo.com
