Hi. I have a large drawing (130 pages) that is best viewed as a flip book. I need to make this drawing available to non-Visio users. Powerpoint works well for presenting items in a flip-book-type fashion. I could copy each Visio page to PPT, but that would take all day. Does anyone have a relatively easy way to export the pages of a Visio drawing into the pages of a PPT file?
Thanks!
If you save all the pages as images could you then import all the images into a PPT slide show?
I have a utility that will save all the pages for you:
http://www.sandrila.co.uk/visio-utilities/?id=117 (http://www.sandrila.co.uk/visio-utilities/?id=117)
you might try a macro like this
al
'
'
'
Public Sub generatePowerPoint()
Dim visDocument As Visio.Document
Dim visPage As Visio.Page
Dim ppApp As PowerPoint.Application
Dim ppSlide As PowerPoint.Slide
Dim iObjCtr As Integer
Dim iConCtr As Integer
Dim iPagCtr As Integer
Dim strForeground As String
Dim strBackground As String
Dim shpGroup As Visio.Shape
Const MAX_SLIDES As Long = 250
Const DEFAULT_AUTO_LAYOUT As Long = ppLayoutBlank
Dim lLastSlide As Long
lLastSlide = 1
Dim lToCreate As Long
lToCreate = 10
Dim lResult As Long
Dim Continue As Boolean
Dim strResult As String
On Error GoTo ErrHandler
Err.Clear
Set visDocument = Visio.ActiveDocument
' start powerpoint
Set ppApp = New PowerPoint.Application
' make it visible
ppApp.Visible = True
' create the presentation
Dim ppPres As PowerPoint.Presentation
Set ppPres = ppApp.Presentations.Add(msoTrue)
lLastSlide = ppPres.Slides.Count
'first we create the pages in the presentation
For iPagCtr = 1 To visDocument.Pages.Count
' we dont want to include the background slides
If visDocument.Pages(iPagCtr).Background = False Then
lLastSlide = lLastSlide + 1
ppPres.Slides.Add lLastSlide, ppLayoutBlank
If Err.Number <> 0 Then
strResult = "Unable to add new slides " & Err.Description
Debug.Print strResult & " Page " & iPagCtr
End
End If ' test for slide being created
End If ' test for background
Next iPagCtr
' now we populate the pages in the presentation
For iPagCtr = 1 To visDocument.Pages.Count
' Debug.Print "powerpoint page " & iPagCtr
strForeground = ""
strBackground = ""
If visDocument.Pages(iPagCtr).Background = False Then
' move page to active window
strForeground = visDocument.Pages(iPagCtr).Name
'If Not (visDocument.Pages(iPagCtr).BackPage Is Nothing) Then
' strBackground = visDocument.Pages(iPagCtr).BackPage
' we can add code here to add background to the slide
' ActiveWindow.Page = strBackground
' but not today
'Else
' strBackground = "NoBackground"
'End If
ActiveWindow.Page = strForeground
ActiveWindow.SelectAll
ActiveWindow.Group
Set shpGroup = ActivePage.Shapes.Item(ActivePage.Shapes.Count)
' Debug.Print "powerpoint objects " & ActivePage.Shapes.Count
' copy selected items to clipboard
ActiveWindow.Copy
' Debug.Print "copied"
' Paste Visio drawing from the clipboard to Powerpoint correct slide
ppPres.Slides.Item(iPagCtr).Shapes.Paste
' now paste the page name into the slides footer as a label
ppPres.Slides.Item(iPagCtr).HeadersFooters.Footer.Text = strForeground
DoEvents
' Debug.Print "pasted"
' now let's ungroup them
shpGroup.Ungroup
' Debug.Print "ungrouped"
' deselect the objects so we dont get confused
ActiveWindow.DeselectAll
' give the system back some time to get things done
End If
DoEvents
Next iPagCtr
ExitHandler:
Exit Sub
ErrHandler:
If Err <> 0 Then
Debug.Print "Error in powerpoint " & Err & " " & Err.Description
Resume Next
End If
End Sub
Thank you. Unfortunately, I tried it and I received a "Compile error: User defined type not defined" when it came to the line "Dim ppApp AS Powerpoint.Application". Any idea how to correct this?
Thanks!
john,
apologies. Since it calls powerpoint you should make sure that when in the vba editor that you go to Tools => References and include the powerpoint that is installed on your system (microsoft powerpoint object library).
al
This is exactly what I needed! Thank you so much!
Possibly related article:
Export All Pages in Document (http://www.visguy.com/2006/09/18/export-all-pages-in-document/)
This code snippet will help you to export all the pages in a Visio document as separate image files. Perhaps a slide-show app can utilize images as well as PowerPoint slides? I've never looked into it, but it seems a reasonable thing to do.
Hi Al,
I'm new to this world. Your above code is great and works brilliantly. I have a challenge where I would like to append visio into an existing powerpoint deck rather than creating a new ppt. Further would be really good to specify a slide number.
Thanks a lot,
aledlund, Happy new year.
Is there a way to modify your code?
I need to export Visio drawings that are a standard 8-1/2 X 11 (Landscape) to a new PowerPoint. Your code does that well, but the height is a little larger than 8-1/2 for some reason. I can easily create an on open macro to correct the height inside PP, but the export would have to go to that macro enabled PP. Would be easier to have the height set when exporting from Visio.
I would love to be able to use Paul Herbers utilities but, my company will not let us download stuff like that to our intranet. :-\
Any help you can offer would be greatly appreciated.
SubPlanner
SubPlanner,
I would first check the size of the pages in your Visio document, since the copy is a straight forward group then copy to clipboard. Are you using a metric page size in the drawing and attempting top place it into a US version of powerpoint? Page sizes within Visio can be manipulated both manually and via VBA but we probably would want to understand why they are appearing in powerpoint as a 'wrong size' first.
Al Edlund
I have the Visio drawing set to 8.5 X 11
It looks like what is happening is the actual drawing within the Visio document shows up in PP as the 8.5 X 11 and any items in the margins close to the edges go over and make it look like I need to adjust.
I included a snapshot of what it looks like when it gets into PP.
PP in background and Visio doc in foreground.
When I do a print preview in Visio, I get the whole document in the with margins and date info on top right.
SubPlanner
I wanted to add this in.
It looks like the default size of the blank PP I a little small.
See insert.
SubPlanner
OMG. Now I find out if I have a protected master that makes up the background of all my pages, Then I make new pages with that background, the only thing that goes into PP are items I placed onto the new page and the background does not show up in PP. :'(
SubPlanner
I saw this posted and it looks like what I need to accomplish an export to PP.
My only problem is my Visio slides are 11 x 17 and the code listed in this post exports to PP in an 8-1/2 X 11 format.
Is there a way to alter the code so when I export the Visio slides out, the receiving PP will be a 11 x 17 format and my Visio slides will fit and look good?
Thanks for the help as always.
FlowerGirl
aledlund,
I have been using this code you posted and it works nicely, but it won't ungroup my separate shapes after pasting into PPT.
Is there something I am missing.
Thanks for you time SubPlanner
Not a problem on 2003 and 2013...I guess chock one up to MS for not messing that up ;-)
for visio ==> power point
From visio
- select shape
- copy
From ppt
- paste or paste special as needed
page shapes copied....background pages not copied
I am using VBA to loop through all the pages to copy paste to PPT.
The code is earlier in this post.
The pasted image will not ungroup.
SubPlanner
that is a whole different issue.
Basically, you want to past a Visio object such that in ppt, you can right click and open the drawing up
to ungroup or whatever.
In office 2003, this worked fine
In later versions of ppt, word...ala office 2010...it does not seem work anymore.
You may want to paste as a visio object in vba (OLE or whatever) and see if it works
( I gave up on this approach 5 years ago)
(note, even if you can make it work, large visio objects will eat up PPt memory, you will get errors like
"ran out of memory"