How to convert numbered/bulleted lists to plain text in Writer?

When preparing documents obtained by OCR for e-books, I often get bulleted lists which I need to convert to plain text (that is, to transform automatic bulleted dashes into plain text dashes – just turning off the bulleted list would make dashes disappear). I have been struggling with this in LibreOffice Writer, while it is easily solved in Word with a simple macro:

Sub Auto_Format_convert_list_numbers()

’ convert_list_numbers Macro
’ Macro created 10/8/08 by WJ Shack

ActiveDocument.ConvertNumbersToText
End Sub

However, that macro won’t work in Writer – I get “BASIC runtime error. Object variable not set”, with the little red arrow pointing to ActiveDocument.ConvertNumbersToText.

Any idea how to modify the macro to work in Writer?

Thanks!

In LibreOffice version 7 (and I’m almost sure in version 6), you can:

  1. Select the bulleted list
  2. Copy it
  3. Toggle off the bulleted list: choose menu Format - Bullets and Numbering… - Remove(the same that F12 for numbering and Shift+F12 for bullets)
  4. Choose menu Edit - Paste Special - Paste Unformatted Text (the same that Ctrl+Shift+Alt+V)

Instead of step 4 (particularly in versions that do not suport Ctrl+Shift+Alt+V), choose menu Edit - Paste Special - Paste Special… (the same that Ctrl+Shift+V) and select Unformatted text.

More LibreOffice Help on Bullets and Numbering.

Maybe you will wish to remove the added spaces before each list item. To do that, you can Find ^[:space:]+ and leave empty the Replace field, check Current selection only and Regular expressions, and press Replace All. See more Help on Find & Replace.


Also, and not a simple workaround as a macro, you can select the bulleted list, and export the selection as PDF. Open, and copy from the PDF.

If there are many bulleted lists in the document, maybe it would be easy to export the complete document as PDF, then copy and paste from there.


Add Answer is reserved for solutions. If you think the answer is not satisfactory, add a comment below. Thanks.

If the answer helped you, you can mark the up arrow (Upvote mark) that is on the left (to vote, you need to have karma of at least 5).

@LeroyG: I’m very surprised at that. OCR usually provides plain text files. Some OCRs are smart enough to enter a carriage return only at end of paragraphs (not at end of every line).

Then such a text file shouldn’t trigger bullet list recognition unless, perhaps, AutoCorrect is enabled. Wouldn’t it be simpler to disable all AutoCorrect options and reimport the OCR plain file? I can’t check because I have no OCR app to see what happens. I have no problem with .txt files.

OP should describe how the OCR’ed text was imported into Writer or tell if the OCR app tries to already format the text (and which one, .doc(x) or .odt?)

  1. ActiveDocument is only available in document’s macros - it won’t be recognized in macros in My Macros & Dialogs container.

image

  1. ConvertNumbersToText is implemented in LibreOffice since version 7.1; but it is not available as Document method - only as ListFormat method. So only the following would work now:
  ActiveDocument.Content.ListFormat.ConvertNumbersToText

Possible workaround:

app=CreateUnoService("ooo.vba.word.Globals").Application
doc=app.ActiveDocument
1 Like