Moving an action button

S

Shane G

Is there a way to create an action button that moves away from the mouse
pointer. So if someone goes to click on it, it just keeps moving away so they
can;t click on it??
 
D

David M. Marcovitz

Yes, this could be done with VBA. You would have to create a macro to
move the button and have it launched on MouseOver. Something like this
might be what you want:

Sub MoveMe(oShp As Shape)
If oShp.Left + oShp.Width > _
ActivePresentation.PageSetup.SlideWidth Then
oShp.Left = 0
Else
oShp.Left = oShp.Left + oShp.Width
End If
End Sub

--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/
 
D

David M. Marcovitz

OK. I got a little carried away and was having too much fun with this. Try
this. Just assign the macro MoveMe to the Mouse Over action setting of the
button you want to have move out of the way. It will randomly move up, down,
left, or right each time the mouse goes over the button.

Sub RandomMove(oshp As Shape)
Dim rndNum As Integer

Randomize
rndNum = Int(4 * Rnd)
If rndNum = 0 Then
MoveMeRight oshp
ElseIf rndNum = 1 Then
MoveMeLeft oshp
ElseIf rndNum = 2 Then
MoveMeUp oshp
ElseIf rndNum = 3 Then
MoveMeDown oshp
End If
End Sub
Sub MoveMeRight(oshp As Shape)
If oshp.Left + oshp.Width + 5 > _
ActivePresentation.PageSetup.SlideWidth Then
oshp.Left = 0
Else
oshp.Left = oshp.Left + oshp.Width + 5
End If
End Sub
Sub MoveMeLeft(oshp As Shape)
If oshp.Left - oshp.Width - 5 < 0 Then
oshp.Left = ActivePresentation.PageSetup.SlideWidth - oshp.Width
Else
oshp.Left = oshp.Left - oshp.Width - 5
End If
End Sub
Sub MoveMeDown(oshp As Shape)
If oshp.Top + oshp.Height + 5 > _
ActivePresentation.PageSetup.SlideHeight Then
oshp.Top = 0
Else
oshp.Top = oshp.Top + oshp.Height + 5
End If
End Sub
Sub MoveMeUp(oshp As Shape)
If oshp.Top - oshp.Height - 5 < 0 Then
oshp.Top = ActivePresentation.PageSetup.SlideHeight - oshp.Height
Else
oshp.Top = oshp.Top - oshp.Height - 5
End If
End Sub
 
D

David M. Marcovitz

You're welcome. Thanks for getting back to us that it is what you wanted.
--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/
 

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