The code below defines an array of pictures that are in the same directory as the powerpoint, then chooses a random picture from the list for the background of every slide.
Public Sub ChangeBackgrounds()
'Global array to store pic names
Dim PictureList(1 To 10) As String
'List of pictures - in same directory as ppt:
PictureList(1) = "048.JPG"
PictureList(2) = "049.JPG"
PictureList(3) = "050.JPG"
PictureList(4) = "051.JPG"
PictureList(5) = "052.JPG"
PictureList(6) = "053.JPG"
PictureList(7) = "054.JPG"
PictureList(8) = "046.JPG"
PictureList(9) = "047.JPG"
PictureList(10) = "059.JPG"
Dim mySlide As Slide
'Iterate through every slide in the presentation
For Each mySlide In ActivePresentation.Slides.Range
Dim PictureChoice
'Give us a random number between 1 and 10 as PictureChoice
PictureChoice = Int((10 * Rnd) + 1)
mySlide.FollowMasterBackground = msoFalse ' Don't follow the master background style
mySlide.Background.Fill.UserPicture (PictureList(PictureChoice)) 'Use our random number to choose a picture from the list
Next mySlide
End Sub
robbi wrote:
Random Background with VBA
15-Oct-08
Hi all
I would like to set up my presentation to choose between a set of random
background images when changing slides. I'd like to test for a particular
layout first and if it passes, then change the slide background. By testing
for the layout, I can make sure the art set is consistent among that set of
slides
So, is this possible? I can't seem to find a way to set the background for
a slide via VBA. Any help is appreciated, thanks
robbie
Previous Posts In This Thread:
Random Background with VBA
Hi all
I would like to set up my presentation to choose between a set of random
background images when changing slides. I'd like to test for a particular
layout first and if it passes, then change the slide background. By testing
for the layout, I can make sure the art set is consistent among that set of
slides
So, is this possible? I can't seem to find a way to set the background for
a slide via VBA. Any help is appreciated, thanks
robbie
Assuming you want change the background for slide 1ActivePresentation.
Assuming you want change the background for slide
ActivePresentation.Slides(1).Design.TitleMaster.Background.Fill.UserPictur
(PicPath
-
Best regards
Edwar
:
RE: Random Background with VBA
If that code fails you may also need to use
Activepresentation.Slides(1).FollowMasterbackground=msoFals
--
Amazing PPT Hints, Tips and Tutorial
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.htm
______________________________
:
And if *that* fails, try SlideMaster instead of TitleMaster ;-)In article
And if *that* fails, try SlideMaster instead of TitleMaster ;-
wrote
----------------------------------------
Steve Rindsberg, PPT MV
PPT FAQ:
www.pptfaq.co
PPTools:
www.pptools.co
================================================
Submitted via EggHeadCafe - Software Developer Portal of Choice
XML into Data Islands Direct from SQL Server 2000
http://www.eggheadcafe.com/tutorial...b-bd916321c72a/xml-into-data-islands-dir.aspx