Periodically someone asks me whether there’s a way to automatically convert all of the pages in a Visio drawing to PowerPoint slides. There have even been a few times when I’ve wanted to do that myself but I never really had enough incentive to figure out the PowerPoint side of it.
One of the reasons I hadn't bothered to solve this problem is built into Visio: if your goal is merely to present Visio drawing pages to an audience, creating PowerPoint slides may be overkill. To present Visio pages, you can just use Visio’s full screen mode by pressing F5 and then navigating from page to page using the arrow keys or PageUp
A recent question here on EE revived my interest in a PowerPoint solution, however, and in one of those wonderful coincidences that sometimes happen, I stumbled across part of the answer while looking for something else!
I was rummaging in the Visio 2007 Software Development Kit (SDK) looking for a way to automate the creation of the very sophisticated time lines Visio can produce (more about that another time…). I did find a potential solution for that problem, but more relevant here, I also found a long-forgotten code sample to create one PowerPoint slide from one Visio page.
Between the PowerPoint code in the sample and the PowerPoint macro recorder -- don’t ever forget about this incredibly useful tool when you’re trying to write code for any Microsoft Office application -- I developed a working solution that saves each page of a Visio drawing as an image, creates a PowerPoint slide, and then inserts the image onto the slide. The program also positions each image in the center of the slide and resizes the image to fit.
The macro creates slides from the active Visio drawing, i.e., the one that is “on top” in the Visio Window. Therefore, to create a set of slides from a Visio drawing:
1) Open the Visio drawing containing the macro.
2) Open the Visio drawing that you want to save as PowerPoint. As an example, the figure below shows the first two pages of a 14 page process map.
3) Select Tools>Macro>Create PPT from Visio >ThisDocument>CreatePowerPointFromVisio
as shown below.
You should now have PowerPoint slides containing your Visio drawing pages as shown in this screenshot.
Notice that the macro creates a title slide and inserts the name of the Visio document from which the slides were made: AUTHOR'S NOTE: Since writing the original version of this article, I've updated the macro code to eliminate the need for the manual steps described in the next six paragraphs. I've left the paragraphs here, however, because the underlying Visio behavior hasn't changed -- you may run into it if you're manually creating images from Visio pages.
When you try this for yourself, if it looks like the images on your PowerPoint slides are all different sizes, you're not seeing things. It turns out that when Visio creates jpg images, it ignores any part of the page that does not contain shapes. To say that a different way, a JPEG created by Visio only contains the shapes and objects on the page, consequently, the JPEG image may be much smaller than the size of the page.
To see an example, look at the side-by-side comparison below. On the left is the original Visio drawing page containing part of a flowchart; notice that most of the page is blank. The image in the PowerPoint slide on the right only contains the flowchart shapes. (For purposes of this article, I added a blue line around the actual image in the PowerPoint slide so you can see its boundaries.)
As a result of this Visio behavior, if you want to create a set of equal-sized JPEGs that contain entire Visio pages, it is necessary to place an object or objects at the edge of each page. The easiest way to do this is to create a background page if your drawing doesn’t already have one, and assign that background page to each foreground page.
On the background page, do one of two things:
Add a rectangle that is the same size as the page, then set fill to No Fill and line color to the page background color, OR
Add a small shape to the top left and bottom right corners of the page, then set line to No Line and fill color to the page background color.
: in the first option, the line must have a color, just as in the second option the fill must have a color. If you set both attributes to No
, the shapes will be invisible to the JPEG creation software and you'll be back where you started.
The screenshot below shows the background page I created for the Visio process map used above. As you can see, I used option 2 by placing tiny white squares in the upper left and lower right corners of the page. The screenshot also shows the line color and fill color settings for the squares -- No Line
is highlighted for the line and the white color is highlighted for the fill.
If you'd like to create PowerPoint slides from Visio drawings you can download the code
. Because I will undoubtedly update this macro periodically, I chose to post it on my web site rather than attach it to this article.
As always, I'd love to hear your thoughts and suggestions for improvements to this code -- just post them below.