using VBA to create a slide show w/ PowerPoint


K

Kevin

I need to create a several slideshows from 200+ pictures, and I need to
do it in PowerPoint.

Rather than inserting each one, I'd like to use VBA to automate the
process.

The file are named sequentially (i.e. Picture 001, Picture 002) and so
I was thinking I could just write some kind of a loop that creates a
new slide, inserts a picture from a given folder with a file name of
Picture %variable% where the variable is a number. Then I would have
it increment, and do it again for all of the pictures.

This is what I've got so far, but it doesn't work because it can't find
the files. I know they're there, so I must have done something wrong.
Any suggestions or help would be greatly appreciated!

Dim counter As Integer
counter = 0

While counter < 73

If counter < 10 Then


ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="C:\Documents
and Settings\Schultz_K\Desktop\Safety Town AM\Flood 00" & counter &
".jpg", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=0,
Top:=0, Width:=721, Height:=541).Select

ElseIf counter < 100 Then


ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="C:\Documents
and Settings\Schultz_K\Desktop\Safety Town AM\Flood 0" & counter &
".jpg", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=0,
Top:=0, Width:=721, Height:=541).Select

End If

Wend

Thanks!

- Kevin
 
Ad

Advertisements

D

David M. Marcovitz

Ad

Advertisements

K

Kevin

David said:
Why reinvent the wheel? Check out:

Batch Insert a folder full of pictures, one per slide
http://www.pptfaq.com/FAQ00352.htm

Also look at this for some non-VBA solutions:

BATCH IMPORT images into PowerPoint
http://www.pptfaq.com/FAQ00050.htm

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

Perfect - thanks!

- Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top