PDA

View Full Version : [SOLVED:] Moving a shape from its original position



fkneg1
11-16-2015, 08:16 AM
Hi,

I'm trying to create a bit of code so that in a presentation, when the mouse is moved over a shape the shape moves to the left.

SO far I have got this code:


Option Explicit
Public myShape As Shape


Sub MoveButton1(oShp As Shape)
Private OrigShpLeft As Integer


Set myShape = oShp
OrigShpLeft = oShp.Left
With oShp
.Left = OrigShpLeft - 20
End With

End Sub

I have set the shape to run the above macro on mouse over but its not working. I'm not sure what I've done wrong or how to find the problem. Does anyone have any ideas?
Thanks

John Wilson
11-16-2015, 11:00 AM
You have already referenced the shape as oshp
.Left is a single but Integer would probably usually work


Sub MoveButton1(oShp As Shape)
Dim OrigShpLeft As Single
OrigShpLeft = oShp.Left
With oShp
.Left = OrigShpLeft - 20
End With
End Sub

fkneg1
11-16-2015, 01:09 PM
Great - that's just what I'm after. Thanks John.