Microsoft Word – Use a VBA Macro to Delete All Images
- Posted by
- Posted on January 28, 2025
- IT Support
- No Comments.
You can use a VBA macro to find and delete all pictures in a Microsoft Word document.
Before starting, make sure macros are allowed in your document.
If they are not, save the file as a “.docm” Word document to allow macros to run.
1.) Press Alt + F11 to open the Visual Basic for Applications (VBA) editor.
2.) Click on Insert and select Module to insert a new module.
3.) Copy and paste the following VBA code into the module:
Sub DeleteAllPictures() Dim shp As Shape Dim inShp As InlineShape ' Delete Shape objects For Each shp In ActiveDocument.Shapes If shp.Type = msoPicture Then shp.Delete Next shp ' Delete InlineShape objects For Each inShp In ActiveDocument.InlineShapes If inShp.Type = wdInlineShapePicture Or inShp.Type = wdInlineShapeLinkedPicture Then inShp.Delete End If Next inShp End Sub
4.) Either click on the green “Run” button..
Or go to the menu, select Run, and then click on “Run Sub/UserForm” from the drop-down menu.
Post Tagged with delete all pictures, delete pictures, macro, macro that deletes images, macro that deletes pictures, Microsoft Word, module, vba, vba macro, vba module, Word
Recent Posts
- Disable Smart Groups for Tabs in Firefox
- Upgrading to Ubuntu 24.04.02 – ” Oh no! Something went wrong “
- Microsoft Word – Use a VBA Macro to Delete All Images
- Powershell Script – Get the Most Recent User Login / Logoff Events
- How to Set a Static IP Address on a Cisco Switch or Router
Archives
- July 2025
- June 2025
- January 2025
- January 2021
- May 2020
- February 2020
- December 2019
- August 2019
- January 2019
- July 2018
Categories
- Computers
- IT Support
- Lab
- Linux
- Management
- Microsoft Applications
- Networking
- Router
- Servers
- Switch
- Uncategorised
- Windows