We help IT Professionals succeed at work.

Is It Possible to Create an Image of a PowerPoint Slide in Visual Basic 2010?

williamzNet used Ask the Experts™

I am trying to loop through all the slides in a presentation and convert them into jpeg images in a PowerPoint (2007) add-in written in Visual Basic 2010.

However, while I can take screenshots using:

 Public Function getScreenShot() As Byte()

            Dim dblScaleFactor As Double
            Dim intNewHeight As Integer
            Dim intNewWidth As Integer
            Dim imgResized As Bitmap
            Dim img As Image
            Dim ms As New MemoryStream()

            Dim picBytes As Byte()

            img = New Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)

            Dim g As Graphics = Graphics.FromImage(img)
            g.CopyFromScreen(0, 0, 0, 0, img.Size)

            dblScaleFactor = 600 / img.Width
            intNewHeight = CInt(dblScaleFactor * img.Height)
            intNewWidth = CInt(dblScaleFactor * img.Width)

            imgResized = New Bitmap(intNewWidth, intNewHeight)

            g = Graphics.FromImage(imgResized)
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
            g.DrawImage(img, New Rectangle(0, 0, intNewWidth, intNewHeight), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel)

            imgResized.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)

            picBytes = ms.ToArray()

            Return picBytes

        End Function

Open in new window

This takes way too long.  I can also get the images exported to disk and then read them back into memory, but this is really inefficiency as well.

Searching  around I found this code that suggests you can paste a slide image into another slide:

ActivePresentation.Slides(2).Shapes.PasteSpecial ppPasteJPG

Open in new window

But I cannot work out how to convert a shape into a Graphics object.

Help would be greatly appreciated!

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Éric MoreauSenior .Net Consultant
Top Expert 2016

Most Valuable Expert 2012
Top Expert 2014
Following code

ActivePresentation.Export(path_to_folder, "JPG")

followed by code to load these images is not as inefficient as taking screenshot of each slide.


Hi Buggy Coder,

Sorry - I am doing that already.  I would like to avoid having to save to disk...

Thanks for the suggestion though.



Hi Emoreau,

Thanks for the suggestion, but I need to be able to copy and work with the resulting slide images in an add-in I am writing.

Thanks for the suggestion though.



Hi Code Cruiser, thanks for the suggestion - will adopt it if there isn't a way of avoiding the writing to disk bit.

After having the question open for a while, no one has suggested a way of doing it by copying, so I am beginning to think it's not possible.

A shame, as I am pretty sure that one can get the slide into the clipboard, but I have no idea how to paste special when I am not pasting into a document.

Going to leave the question open for a couple of days more in case there is a way...




It appears that it is not possible to copy and then retrieve the data as images from the clipboard...