vba to find action buttons?

G

Geoff Cox

Hello,

I have several hundred presentations in which the last slide should
have an action button on it.

How would I test each presentation to see if the action button has
been added?

The code to create the action button is

With ActivePresentation.Slides(ActivePresentation.Slides.Count)_
..Shapes.AddShape(msoShapeActionButtonForwardorNext, _
586.75, 496.75, 96.38, 28.38)

Thanks for any pointers.

Geoff
 
G

Geoff Cox

Before making mass changes to a file or file, make a backup of any files you
plan to alter.

Steve,

I am so aware of this that I have endless backups!
add immediately after this line:

.Name = "GeoffsActionButton"

excellent idea.
I'm guessing that adding another next button directly atop the first wouldn't
hurt anything but ...

In fact I think it does matter. That's how the problem came to light.
I found that some buttons were not working and then realised that I
had one on top of another and the top one would not work. The one
underneath was OK.

Not sure what your code is doing. What is it deleting? I was more
thinking of a message saying "no button in file <name of file>" if the
button was missing ....

Cheers

Geoff
 
G

Geoff Cox

On Tue, 18 Apr 2006 23:51:21 EDT, Steve Rindsberg

Steve,

Well blow me down!! I combined your code with the previous code for
adding the button - minus the adding button part - with a good deal of
guess work and low and behold the code does run!

But! Your code below removes 1 button I think. So that means that if
there was only 1 button - the correct situation - it will be removed.
If there were 2 buttons - extra one placed in error by my running a
macro twice - then the second button would be removed.

This does not allow me to find the ppt files with no button or those
with 2 (or more buttons)?

I guess I am looking for code which will indicate

1. no button in this file (ie name of file given) OR

2. more than 1 button in this file (name given)

Am I missing a logic trick here?

Or, more easily perhaps, code which removes all such action buttons in
each of the last slides - then at least I would know that all files
had no button/s and could then safely run the macro to create the
button in each end slide....

Cheers

Geoff



Dim oSh as Shape

For Each oSh in _
ActivePresentation.Slides(ActivePresentation.Slides.Count)_
.Shapes
if oSh.type = 1 then
' 130 = msoShapeActionButtonForwardOrNext
if osh.autoshapetype = 130 then
osh.delete
end if
end if
Next
 
G

Geoff Cox

No ... computers and often the people who drive them are frightfully literal
minded. You didn't ask for help removing multiple buttons or hint that there
might even be more than one.

Steve,

If we are to be literal (!) - I actually asked "How would I test each
presentation to see if the action button has been added?"

I didn't ask "how could I delete the buttons that were on the slides".

By "testing" I was looking for a way of knowing if the button was
there or not there. Deleting buttons doesn't tell me that does it?!

Cheers

Geoff
 
G

Geoff Cox

Geoff,

I'd suggest that you get a good book on writing VBA for PowerPoint (David
Marcovitz' book is not only good, it's pretty much the only one available) and
learn to do some of this yourself.

Those of us who do VBA here are happy to help anyone past the rough spots, but
for the most part, we're not here to write entire free addins for people.


Steve,

Quite correct - thanks for your help to date - will buy the book now!

Cheers

Geoff
 
Top