Pixel-accurate drawing in PowerPoint; measuring in pixels
Problem
You plan to export a PowerPoint slide at a specific resolution (number of pixels) and want to be able to enter sizes and positions IN pixels as you create your drawing, but PowerPoint only accepts inches, points, cm, mm, etc as dimensions.
Or you know that you'll be displaying your presentation on a monitor or projector of a certain size (in pixels) and want to be able to work in pixel units instead of inches or points or centimeters.
Solutions
In more recent versions of PowerPoint, you can now enter pixels as units of measurement. In any text box that allows you to enter a measurement, enter, for example, 96pixel, 96pix or even 96px. PowerPoint will convert that to inches or cm (depending on your Windows measurement settings) at 96 dpi, usually. This may or may not produce the result you're after. If not, read on.
Another approach is to set your page size up correctly before starting to draw. If you need to export images, use a little VBA code (or the PPTools ImageExport add-in).
For example, to create a 500 pixel by 100 pixel banner:
- Change your PowerPoint page size to 5 x 1 inch.
- Create your drawing; enter any measurements in .01 inch ... every .01 inch will become 1 pixel in the final exported image.
- Use PPTool ImageExport to export the image to 500 pixels wide or run the code below.
Here's the code to export the currently selected slide to an image. Don't be startled if the text looks like the dog chewed on the edges. PowerPoint exports ugly text. ImageExport exports pretty text. You get to choose. Nice.
Sub ExportAnImage() Dim sExportFile As String Dim sExportType As String Dim lheight As Long Dim lwidth As Long ' EDIT THESE LINES: sExportFile = "C:\Temp\PixelAccurate.PNG" sExportType = "PNG" ' make sure that width/height is proportional to slide width/height lwidth = 500 lheight = 375 ' DON'T CHANGE ANYTHING ELSE With ActiveWindow.Selection.SlideRange(1) .Export FileName:=sExportFile, filtername:=sExportType, _ Scalewidth:=lwidth, Scaleheight:=lheight End With End Sub
See How do I use VBA code in PowerPoint? to learn how to use this example code.
Background
This all came up in one of the sessions at PowerPoint Live 2009 when Ellen Finkelstein asked why we couldn't use Pixels as a unit of measurement in PowerPoint instead of the usual inches, cm, points etc.
For most uses of PowerPoint, this doesn't make a lot of sense because PowerPoint sizes its output to match the current printer or monitor, however many pixels that'll take. Since you can't know ahead of time how large the output will be, you can't specify in advance how large to make any one shape.
But once Ellen explained that she was creating web graphics and knew in advance that she'd export her slides to a certain size, THEN we had a problem we could solve.