A family of Microsoft presentation graphics products that offer tools for creating presentations and adding graphic effects like multimedia objects and special effects with text.
This thread talk about to use macros to apply some settings for the picture, not to load a random picture.
Make a new presentation and add an image control to the first slide and save it in the same directory with your pictures.
With Office 2007 we must establish some code first to locate the pictures. Download this file, open the VBA editor, press CTRL-M and import it. This creates a class module FileSearch in your project.
http://dl.dropbox.com/u/35239054/FileSearch.cls
Then add a normal module to your project and paste in the code below. Every time you call this macro the pictures within the image control changes. Note: You must close the presentation before you add or remove pictures in the directory, otherwise the code may cause errors.
Andreas.
Option Explicit
Sub LoadRandomPicture()
Dim S As Shape
Static FS As FileSearch
'Visit all Shapes
For Each S In ActivePresentation.Slides(1).Shapes
'Is it an OLEobject?
If S.Type = msoOLEControlObject Then
'Is it our image?
If TypeOf S.OLEFormat.Object Is MSForms.Image Then
'Yes, search for the files if not already done
If FS Is Nothing Then
'Initialize FileSearch
Set FS = New FileSearch
With FS
'Search for loadable pictures
.FileName = Array("*.jpg", "*.bmp")
'In this path
.LookIn = "C:\pictures"
'And it's subfolders
.SearchSubFolders = True
'Do it
If .Execute = 0 Then
MsgBox "No pictures found in """ & .LookIn & """, abort."
Exit Sub
End If
End With
End If
'Select a random picture
S.OLEFormat.Object.Picture = LoadPicture(FS.FoundFiles((Rnd * FS.FoundFiles.Count) + 1))
End If
End If
Next
End Sub