assigning same function to the actions of every picture in a photo album

K

kaston3

I have a ppt photo album show - each slide consists of a single
picture.

I know how to assign a function to the mouse click for every picture
using the ppt interface but I need to do it through VBA code so as not
to have to go over all the pictures one by one.

What Visual Basic array/collection contains the pictures in a show or
slide and how do I refer to them in VBA?

I want to use a for...next loop and action>function assignment in the
loop.

Thanks
 
K

kaston3

for each picture mouse click->assign macro

I know how to do it picture by picture ->just rightclicking on picture
and choosing action configuration>mouse click>macro, here a pulldown
list of available functions/macros appear.

I also know the Visual BASIC algorithm and where to put (alt+f11)

What I need is a way to refer to a particular picture in a slide.

for example the following is used to refer to the current pesentation
like ActivePresentation.SlideShowWindow:


1. How can I refer to
a) slide 1, 2, 3 and so on
b) A picture loaded into each slide at design time

2. How can I assign a macro to a mouseclick on each picture:
(the names inside the for..next loop are made up. That's what I need
to know: their actual name in Visual basic for Applications.

for x= 1 to ActivePresentation.Slides.Count
slide(n).picture(1).action.mouseclick=mymacro()
next
 
K

kaston3

Thanks for that code, It doesn't seem to work, though. The mouse action
does not get assigned to the pictures at run time.

I assigned your DoSomethingToAllThePictures() procedure to a mouse
click action for a picture in the first slide. That is, the picture
assignment at run time should occur to all pictures from number 2 to
number of slides. I also want to randomize the show order of those
slides and that works ok with another routine triggered in the first
slide mouseclick but the call to your code does not work.

I even tried diferent ways to call the sub like

..Run = thesub (with no quotes) or thesub().
 
K

kaston3

Yes. Running the macro that assigns the actions just one at design time
makes more sense. However I did it that way and only the picture of the
first slide gets assigned the sub. There has to be some problem in the
loop that stops it at the first slide.

I tried using different sub and funtions and the code works BUT only
for slide 1.

(I think the old for...next loop is easier to understand and wonder how
to do it using for... next instead of for each...next)

Thanks
 
K

kaston3

"Works for slide one" means that the action gets assigned to the
picture of the slide as intended but only the first slide (Obviously I
check the actions in the other pictures/slides and there is no action
assigned to them).

I just did some testing -- creating a mini presentation with three
pictures-- and it seems that the problem is that all slides/pictures
except slide one were created using the photo album feature in
powerpoint 2003.

So it looks like there no difference since I get the same options when
I click on them but there has to be some difference in the way the
pictures are treated as powerpoint objects when loaded with photo
album.


When in your code there's:
Case Is = msoPicture, msoLinkedPicture

the pictures loaded using photo album are not recognized as msoPicture
type or msoLinkedPicture --

So, what kind of object can they be??
 
K

kaston3

OK, that was the problem. Pictures loaded using the photo album feature
are loaded as autoshapes -- I only needeed to change that in your code



msoAutoShape instead of msoPicture

Now everything works. The photoalbum and your code have saved me lots
of time since I have to do this with many other collections of
pictures.

Thanks for your time!
 
D

David M. Marcovitz

I'm glad you got it to work. Just beware that msoAutoShape is a broad
category, so you might end up with lots of stuff containing links to
macros if you have a lot of non-picture autoshapes.
--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.loyola.edu/education/PowerfulPowerPoint/
 

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