How to Add Alt Text in Bulk to All PowerPoint Pictures With VBA
🔍 WiseChecker

How to Add Alt Text in Bulk to All PowerPoint Pictures With VBA

Adding alternative text alt text to every image in a PowerPoint presentation improves accessibility for users with screen readers. Doing this manually for dozens or hundreds of slides takes too much time. You can use a Visual Basic for Applications VBA macro to add alt text to all pictures at once. This article explains how to create and run a VBA macro that adds a standard alt text string to every picture in your presentation.

Key Takeaways: Bulk Alt Text With VBA in PowerPoint

  • Alt + F11 to open the VBA editor: Opens the Microsoft Visual Basic for Applications window where you paste the macro code.
  • Alt + F8 to run the macro: Opens the Macro dialog box so you can select and execute the bulk alt text macro.
  • Shape.Type = msoPicture check: The macro scans only shapes that are pictures, skipping text boxes and other objects.

ADVERTISEMENT

What the VBA Macro Does for Alt Text

The macro loops through every slide in the active presentation. On each slide it checks every shape to see if the shape is a picture. If the shape is a picture and its alt text field is empty, the macro writes a default alt text string. You can edit the default string in the code to match your organization’s accessibility policy.

Before you run the macro, save your presentation. The macro changes the presentation file. If you make a mistake, you can close the file without saving and reopen the original. No external add-ins or downloads are required. VBA is built into PowerPoint on Windows.

Steps to Add Alt Text in Bulk to All PowerPoint Pictures With VBA

Follow these steps to create and run a VBA macro that adds alt text to every picture in your presentation.

  1. Open the VBA editor
    In PowerPoint, press Alt + F11 on your keyboard. The Microsoft Visual Basic for Applications window opens.
  2. Insert a new module
    In the VBA editor menu bar, click Insert and then click Module. A blank code window appears.
  3. Paste the macro code
    Copy the following code and paste it into the blank module window:
    Sub BulkAddAltText()
        Dim sld As Slide
        Dim shp As Shape
        Dim altText As String
        
        altText = "Decorative image"
        
        For Each sld In ActivePresentation.Slides
            For Each shp In sld.Shapes
                If shp.Type = msoPicture Then
                    If shp.AlternativeText = "" Then
                        shp.AlternativeText = altText
                    End If
                End If
            Next shp
        Next sld
        
        MsgBox "Alt text added to all pictures."
    End Sub
    
  4. Edit the default alt text optional
    In the line altText = "Decorative image" replace the text between the quotes with your preferred alt text. For example: altText = "Photo of product demonstration"
  5. Run the macro
    Press Alt + F8 to open the Macro dialog box. Select BulkAddAltText from the list. Click Run. A message box confirms alt text was added.
  6. Verify the alt text
    Right-click any picture in your presentation. Select Format Picture. In the Format Picture pane, click Size and Properties the icon with a square and arrows. Expand Alt Text. The text you set appears in the Description field.

How to Modify the Macro to Skip Pictures With Existing Alt Text

The code above checks If shp.AlternativeText = "" before writing. This means pictures that already have alt text are not overwritten. If you want to overwrite all alt text regardless, remove the If and End If lines around the assignment.

How to Add Unique Alt Text Per Picture

The macro in this article sets the same alt text for every picture. To add unique alt text you need a different approach. You can write a macro that reads the file name of each inserted picture and uses the file name as alt text. Alternatively, you can loop through pictures and prompt the user for each alt text entry. The basic macro above is the fastest method for bulk adding a consistent alt text string.

ADVERTISEMENT

Common Issues When Using the VBA Macro

Error: “The macro cannot be found or has been disabled”

This error appears when the presentation is saved as a .pptx file after the macro was added. The .pptx format does not store macros. To fix this, save the presentation as a PowerPoint Macro-Enabled Presentation with the .pptm extension. Go to File > Save As and choose PowerPoint Macro-Enabled Presentation from the file type list.

Macro does nothing and no error appears

The macro runs but no alt text is added. This usually means the shapes are not recognized as pictures. Some images are inserted as linked pictures or as OLE objects. Linked pictures have shp.Type = msoLinkedPicture. OLE objects have a different type. To handle linked pictures, change If shp.Type = msoPicture Then to If shp.Type = msoPicture Or shp.Type = msoLinkedPicture Then.

Alt text appears in Title field instead of Description field

The property shp.AlternativeText writes to the Description field in the Alt Text pane. If you want to write to the Title field, use shp.Title instead. Screen readers typically read the Description field first. It is best practice to use the Description field for meaningful alt text.

VBA Bulk Alt Text vs Manual Alt Text: Comparison

Item VBA Macro Manual Entry
Time per 100 pictures Less than 5 seconds 15 to 30 minutes
Alt text uniqueness Same text for all pictures unless modified Can write unique text for each picture
Risk of errors Low if code is correct High due to repetitive typing
Requires macro-enabled file Yes .pptm format No any file format works
Accessibility compliance Consistent but may need review Can meet WCAG exactly

You can now use VBA to add alt text to every picture in a PowerPoint presentation in seconds. The macro saves time for large decks and ensures no image is left without alt text. For more advanced scenarios, modify the macro to read image file names or to prompt for custom text per slide. Always test the macro on a copy of your presentation first.

ADVERTISEMENT