#PowerBI Convert all Power BI links in Power Point to images

Yesterday I posted an image of some PowerPoint VBA code on LinkedIn and Twitter and a lot of people have asked for a copy of the code.

So I have made a Power Point file with the code included and a small instruction on how to use it.

The code has been changed compared to the posted image as it ran to fast for Power Point – so I added a pause in the code to wait 1 second for each conversion.

The Code

Sub ConvertAllPBIToImages()
Dim x As Slide
Dim shp As Shape

Dim sShapes As Shapes

'Loop through all the slides
For Each x In ActivePresentation.Slides

    x.Select
    'Loop through all the shapes on the slide
    For Each shp In x.Shapes

        'Is it a Power BI App - Report
        If shp.Title = "Microsoft Power BI" Then

            'Inserted to make sure as the code sometimes runs
            'a bit to fast for Power Point
            WAIT = Timer
            While Timer < WAIT + 2
               DoEvents  'do nothing
            Wend

            shp.Copy

            Set sShapes = x.Shapes

            x.Shapes.PasteSpecial ppPasteBitmap

            shp.Delete

        End If
    Next
Next

End Sub

Here is a link to a file with the code.

LINK

Hope you find it useful.

10 thoughts on “#PowerBI Convert all Power BI links in Power Point to images

  1. I’ve tried the macro again and again, but it seems not working. I had tried step by step, bit the shape (AddInn) object will be not selected. Are there some changes with current add inn versions?

      1. Hello Erik, no error message. Macro runs, goes from slide to slide, but shapes will not be activated and not transferred to image.

      2. Hi

        The code expects the shapes with the Power BI visual should have a title called Microsoft Power BI .

        Apparently the Add-in has been updated so the title is empty – this means that the shape with Power BI visual isnt found and thereby no conversion takes place.

        If you modify the name of the visual via the selection pane – to “Microsoft Power BI”

        and change the code line

        If shp.Title = “Microsoft Power BI” Then

        to

        If shp.Name = “Microsoft Power BI” Then

        then it should do the trick

        Erik

      3. Perfect, thank you, that works!
        Do you also have a trick, in case I only wants to freeze the data for all Power BI shapes (functionality β€œshow as Saved Images”)?

  2. Hello Erik

    This looks promising but it pastes the static image in the middle of the slide instead of where the PowerBi visual was. Is there anyway to get it to retain the location of the original visual?

Leave a comment