How open a LibreOffice Writer file and read document to string in Writer Macros Basic

How do I open a LibreOffice Writer file and read document to a string and close document in Writer Macros basic.

What do you want to get in your string?

  • the actual file (binary, representing a zip file)
  • the unpacked contents.xml, including all odf-formatting as xml-entities
  • a string representation of the text without any formatting
  • or you even may want an array of strings, where every string represents a paragraph

One of the simpler solutions may be to Save-As .txt and only select a charset. You may then read the exported file bach to your structure.

J.

First, you need open file, look:
https://wiki.documentfoundation.org/Macros/Basic/Documents#Open_documents

Then, read all text

text = doc.Text.String

finally, close document:

doc.close(True)

Thank.you.

Please, if the answer solves the question click :heavy_check_mark:.