A shapes position can be read and controlled by its top and left properties.
As a reminder, most visible things on PowerPoint slides are shapes.
Let's see the position of this text box.
We'll use a function to get the textbox since I'll be using this logic several times.
Function getTextBox() As Shape
Set getTextBox = ActivePresentation.Slides(1).Shapes("textBox1")
End Function
Now show the position with this subroutine
Sub showShapePosition()
Set tb = getTextBox
Debug.Print "textbox Left: " & tb.Left
Debug.Print "textbox Top: " & tb.Top
Debug.Print "textbox Right: " & tb.Left + tb.Width
Debug.Print "textbox Bottom: " & tb.Top + tb.Height
End Sub
The shape object doesn't have a Right and Bottom property, so we calculate it from the Right as Left + Width and Bottom as Top + Height.
Executing...
No surprises here, the top-left coordinate is 0, 0.
Let's move the textbox to the top-right and see what the coordinates are.
Top is still 0 -- no surprise. Right is 960.
Now if you are like me, you were asking 960 in what units?
It takes some digging, but the unit is .... Points
In display terms, a point is 1/72 of an inch. 72 points is an inch.
The bottom line is you can treat this like a fixed coordinate system.
The only thing that can change is the bottom right if you change the aspect ratio of your slides - which would be a very deliberate action.
Let's move the text box to the bottom right and run showShapePosition
The value to note here is bottom. Bottom is 540.
And finally to bottom-left and showShapePosition
Left is 0 and Bottom is 540 as we would expect.
Let's programatically get the slide's size.
Sub showSlideSize()
Debug.Print "slide width: " & ActivePresentation.PageSetup.SlideWidth
Debug.Print "slide height: " & ActivePresentation.PageSetup.SlideHeight
End Sub
Now that we know how to get the slide's size, we can use this to move any shape.
First lets move the shape to the bottom right.
Sub moveShapeBottomRight()
Set tb = getTextBox
tb.Top = ActivePresentation.PageSetup.SlideHeight - tb.Height
tb.Left = ActivePresentation.PageSetup.SlideWidth - tb.Width
End Sub
We have to make room for the shape's height, so we make its top Property the Slide height - the shape's height.
Same concept for the shape's width.
Now top right
Sub moveShapeTopRight()
Set tb = getTextBox
tb.Top = 0
tb.Left = ActivePresentation.PageSetup.SlideWidth - tb.Width
End Sub
Now bottom left
Sub moveShapeBottomLeft()
Set tb = getTextBox
tb.Top = ActivePresentation.PageSetup.SlideHeight - tb.Height
tb.Left = 0
End Sub
now top left
Sub moveShapeTopLeft()
Set tb = getTextBox
tb.Top = 0
tb.Left = 0
End Sub
now in the middle of the slide - both width and height
Sub moveShapeMiddleMiddle()
Set tb = getTextBox
tb.Top = ActivePresentation.PageSetup.SlideHeight / 2 - tb.Height / 2
tb.Left = ActivePresentation.PageSetup.SlideWidth / 2 - tb.Width / 2
End Sub
You could use these same techniques to move one shape relative to another shape rather than relative to the edges of the slide.