How can I determine if a paragraph in my text document contains images using Basic macros?
Thank you!
See Andrew Pitonyak’s text’s. Useful Macro Information 7.16.4 and 7.16.5 link here.
His documentation and examples of Oo and LO macro use are a valuable resource for macro users.
Thank you echo8hink for a very useful answer! I have found a solution.
Function inlineShapesStyles(ByVal styleName As String)
Dim oVCurs As Object ' The view cursor
Dim oTCurs As Object ' The text cursor
Dim oText As Object ' Text object that contains the view cursor
sTContentService = "com.sun.star.text.TextContent"
' The view cursor knows where a line ends
oVCurs = ThisComponent.CurrentController.getViewCursor()
' The text object that contains the view cursor
oText = oVCurs.Text
' Require a text cursor so that you know where the paragraph ends.
' The view cursor is not a paragraph cursor.
oTCurs = oText.createTextCursorByRange(oVCurs)
oTCurs.gotoStart(False) ' Begins the search at the start of the document
' Iterates paragraphs
For i = 0 To ThisComponent.ParagraphCount
inlineTextShape = False
' Require a text cursor so that you know where the paragraph ends.
oTCurs.gotoStartOfParagraph(False)
oTCurs.gotoEndOfParagraph(True)
' Enumerates graphics (does NOT work to enumerate text fields)
oEnum = oTCurs.createContentEnumeration(sTContentService)
Do While oEnum.hasMoreElements()
oSect = oEnum.nextElement()
If oSect.ShapeType = "FrameShape" Then
'If oSect.ImplementationName = "SwXTextGraphicObject" Then ' optional
oTCurs.ParaStyleName = styleName
msgbox "Shape found"
Exit Do
End If
Loop
oTCurs.gotoNextParagraph(false)
Next i
End Function