How can I find a Formula object in a paragraph?

I can enumerate the embedded objects in the document as follows:

Sub LookAtEmbeddedObjects
 Dim oDoc
 Dim oEmbed
 Dim oObj
 Dim i As Integer
 Dim s As String

 oDoc = ThisComponent
 oEmbed = oDoc.getEmbeddedObjects()
 s = ""
 For i = 0 To oEmbed.getCount()-1
   oObj = oEmbed.getByIndex(i)
   If oObj.supportsService("com.sun.star.text.TextEmbeddedObject") Then
     If oObj.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997" Then
       s = s & oObj.getEmbeddedObject().Formula & CHR$(10)
     End If
   End If
 Next
 MsgBox s
End Sub

I used a simple enumeration of the text object, and I even found the text section containing the formula. I only know this, however, because I used a very simple document with simple text and a formula (or two). The enumeration starts as follows:

 oParEnum = oDoc.getText().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()

I can perform comparisons such as:

If oSect.supportsService("com.sun.star.text.TextField") Then

or even

If NOT IsNull(oSect.Bookmark) Then

If I call getString() on the section, it returns an empty string, and the text content type appears to be Frame, which I did not expect.


--
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]

Reply via email to