How to delete all Pictures or Images from word document
If your Word document has lots of pictures scattered throughout your document and you want to delete all of them, deleting these pictures or images one by one manually is very time consuming and tedious task. Here in this post. By using Macros and VBA (Visual Basic for Applications), you can automate this process, saving a significant amount of time and effort. Here in this post, I am going to explain how you can delete all images from word document at once with just a single click using Macros and VBA code.
- Open the Visual Basic for Applications (VBA) editor or IDE by Pressing Alt + F11 (Alt plus F11).
OR from the Ribbon click on Developer Tab and then from the code group click on Visual Basic.
(if developer tab is not visible on your word Ribbon, click here to enable it in your MS Word)
This will open VBA IDE(Integrated Development Environment) as bellow.
- In the VBA editor, from the menu click on Insert > then click on Module to create a new module.
- Past or type the following code into the module
Sub Delete_All_images()
For Each img In ActiveDocument.InlineShapes
img.Delete
Next img
End Sub
And Click On Save icon (or Click on Run Icon) and Close the VBA editor as shown bellow.
- To test the Macro press ALT+F8 or (FN+ALT+F8) Macro Dialog Box will appear (Containing list of VBA Macros) as bellow, here select the Macro you have created such as “Delete_All_images” and Click on RUN Button.
After clicking on run button your VBA Macro (Delete_All_Images) will be executed and All images from your current word document will be deleted.
I hope this tutorial will help you to delete all images from word document using VBA Code. If you have any question, suggestion or feedback feel free to contact us using the information provided on our contact us page.
Thank you.