PDA

View Full Version : Moving a Shape to position



Exposian
04-29-2015, 10:43 AM
Hello All!

Hoping there is an expert out there who has the answer...

I have a piece of code (below) that position a selected shape to a given position on a click of a button.

What I would like to do (Not sure if it can be done) is to have multiple positions sequence for the selected shape then a loop with the same button.

For example:
I click the button once, then the shape moves to .Top = 100
I click the button again, then the shape moves to .Top = 250
I click the button again, then the shape moves to .Top = 300
I click the button again then it loops back up to moves to .Top = 100
And so on...

Is that do-able? I do not want to use increment as the positions are all different...

Hope someone can help on that one!

Best regards,
Philippe



Sub MoveMe()

Dim o As Shape, b As Boolean
Set o = ActiveWindow.Selection.ShapeRange(1)
If Not o Is Nothing Then
With o
.Top = 359.1945
End With
End If
Exit Sub


End Sub

John Wilson
04-29-2015, 11:10 AM
I can.t see how you have that code working on click. Buttons only work in show mode and that code will certainly fail outside of edit mode.

In show mode this would work


Sub MoveMe(oshp As Shape)
Const Pos1 As Single = 100
Const pos2 As Single = 250
Const pos3 As Single = 300
Select Case oshp.Top
Case Is = Pos1
oshp.Top = pos2
Case Is = pos2
oshp.Top = pos3
Case Else
oshp.Top = Pos1
End Select
End Sub

Exposian
04-30-2015, 10:09 AM
Hi John!

Many thanks for taking the time to help! I will try that option...

Best regards,
Philippe

Exposian
05-01-2015, 03:54 AM
Hi all,

I had a question about position value... How can I use centimeters instead of points? I'd like to use measurement like 0.46cm

Best regards,
Philippe

John Wilson
05-10-2015, 07:40 AM
Have a look at our page here

http://www.pptalchemy.co.uk/PowerPoint_cmToPoints.html

Exposian
05-11-2015, 06:54 AM
Wonderful!!!! Thanks a lot John!

Regards,
Philippe