Hello,
I'm trying to solve the following task.
I have a document with mix of "usual" paragraphs and bulleted list.
What I want to make is an automatic change from bulleted list to paragraph
with a prefix.

Like

Paragraph 1

   - list eement  1
   - list element 2

Paragraph 2

->

Pragraph 1 (unchanged)
* list element 1 (list element 1 -> paragraph with * prefix)
* list element 2 (list element 2 -> paragraph with * prefix)
Paragraph 2 (unchanged)

Seems to be I need to write a macro for it, but all ChatGPT gave me are not
working )
Like this one
Sub ConvertBulletsToDashes()
    Dim oDoc As Object
    Dim oParagraphs As Object
    Dim oPara As Object
    Dim oText As Object
    Dim i As Integer

    oDoc = ThisComponent
    oParagraphs = oDoc.Text.createEnumeration()

    While oParagraphs.hasMoreElements()
        oPara = oParagraphs.nextElement()

        ' Check if the paragraph is a list item
        If oPara.supportsService("com.sun.star.text.Paragraph") Then
            If oPara.NumberingIsNumber Then
                ' Get the text and replace the bullet with a dash
                oText = oPara.String
                oPara.String = "- " & Trim(oText)
                oPara.NumberingIsNumber = False ' Remove list formatting
            End If
        End If
    Wend
End Sub

Any hints are appreciated, thanks!
-- 
Best regards,
Ihor (Igor)

-- 
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy

Reply via email to