Ubuntu 12.04

I want to remove all the images from a document in LibreOffice Writer. My document contains ~ 350 images. Is there a way to delete them en masse rather than one by one? I tried unchecking Tools > Options > LibreOffice Writer > View > Display > "Graphics and objects". But the place-holders are still visible.

Edit: I know about saving the page as a plain text file, But I need formatting in my document.

  • @Chelia: Have you tried saving the document as a text only file (in the "save as" preferences)? Commented Feb 22, 2013 at 11:11
  • But why does unticking "options>libreoffice writer>view>Display> "Graphics and objects"" not work? I tried it. It works for me. With that setting ticked, the next time I open any document with graphics, I just see the place-holders.
    – user25656
    Commented Feb 22, 2013 at 11:14
  • he'd still need to remove the placeholders @vasa1 :)
    – Rinzwind
    Commented Feb 22, 2013 at 11:21
  • True! But it's not clear what the final aim is or why OP doesn't want to see the images. Exporting as a text-only file may kill a lot of formatting.
    – user25656
    Commented Feb 22, 2013 at 11:25
  • exactly..! I will lose all formatting if I save it with only text.
    – Chella
    Commented Feb 22, 2013 at 12:09

3 Answers 3


You can also use a short macro from within LibreOffice to remove all images in a document:

Sub RemoveImages

   Dim oDoc as Object
   oDoc = ThisComponent

   Dim oGraphics as Object
   oGraphics = oDoc.getGraphicObjects()

   Dim oImg as Object

   For Each oImg in oGraphics

End Sub

This example could also be modified to change the properties of images (such as making them all a uniform size) as well as handling shape objects, etc.

Creating Macros

LibreOffice provides a Basic language as well as in IDE to create, debug, store, and run code.

To open the macro dialog, use Alt + F11 or, from the menu, Tools > Macros > Organize Macros > LibreOffice Basic

Code is placed in modules, which are organized into libraries. You can create your own, but for most purposes you can use the built-in MyMacros library and the built-in Module1.

Once the macro dialog is open, highlight Module1 and press Edit. This opens the IDE.

Code is organized into Subs and Functions. Borrowing from VBA, Functions are used to return a value and Subs do not return a value. You can define your own subs and functions anywhere below Main. So to use this code to remove images, you just paste it in the module.

Using Macros

You can run the code right from the IDE by clicking anywhere inside the Sub you want to run and press F5. (Functions, since they return a value, need to be called from a Sub.) You can also use the dialog buttons or menu to run the code. The IDE includes an integrated debugger, which is crucial when writing new code.

The next time you open the macro dialog, you will see the sub listed as a macro and it can then be run without opening the IDE. Individual macros can also be assigned to menu or toolbar items.

Note: This macro will run on whatever is the active document. When running a macro from the menu or macro dialog, this can be assumed to be the document where you just pressed the button; but when using the IDE to create, run, or debug code, make sure you haven't made another document the active document.

LibreOffice Basic

LibreOffice Basic is very similar to VBA, but that similarity can also be deceiving since the object model is completely different and the syntax also has many differences.

For example, in VBA, once you have a reference to an image object, the image object would have a delete method. Here, objects have or inherit very few methods. To delete the image object, you use the document element with a structure and syntax very similar to a browser-based DOM.

LibreOffice Help has links for getting started with LibreOffice Basic.

  • If it's not too much trouble, a little instruction on how actually convert the code to a macro may be helpful. Given all the cries about Java, people should also know that a JRE is needed to allow macros to work. Let's hope that LibreOffice finally gets Java-free.
    – user25656
    Commented Feb 23, 2013 at 6:48
  • Genius. :) And still works in LibO Writer 5.1, it might be worth adding.
    – Dɑvïd
    Commented Mar 26, 2016 at 11:12

I'm assuming that the text of the document is formatted and that saving as text-only isn't ideal. In that case, one could take a somewhat longish approach:

  • Create a temporary folder.

  • Open the document in LibreOffice normally.

  • Choose Save As and here select HTML Document (Writer) (.html) as the format.

    • Also, specify the temporary folder for the destination and give the proposed html file a suitable name. Agree to Save as html and not odt format in the next screen.
  • Close LibreOffice.

  • Open the temporary folder created above. You should see one html file and a bunch of images.

    • Delete the images if they're not needed further.
  • Then, open the .html file in an appropriate text editor to strip out the tags that would otherwise, if left in, cause gaps in the document.

    • For example, in Geany, I used <IMG SRC="[^>]+> as the search expression and nothing in the "replace with" box.


  • Save the .html file. Now, when viewed in a browser or even in LibreOffice, there will be no images, no placeholders, just formatted text.

Edit: Instead of using a GUI-based text editor, assuming one is in the relevant folder and that cli.html is the name given while saving to html in LibreOffice, one could just use the command line this way:

perl -p -i.bak -e 's/<IMG[^>]+>//g' cli.html

A backup file, cli.html.bak, is created just in case ...


You can select one image in document via mouse, then press Ctrl + A for select all images in current Sheet, and Del for delete them.

  • simple, and best of all, it works! thank you
    – kjones
    Commented Feb 11, 2021 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .