Share via

VBA Code - Move all objects by set distance

Anonymous
2018-05-08T17:23:05+00:00

Hi All,

Is there a way in powerpoint to move all objects on a slide by a set distance - being 7.195cm to the "right".

I have a deck that the slide size needs to reduce, but my content is offset so I need to move it back to it's relative correct position.

I have about 200 slides to do this to so I was hoping that there was a VBA code that I could modify for this.

Thanks

James

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2018-05-09T21:10:51+00:00

You need at least 2013 to use vba on guides

Even then you cannot move them but you can add a new guide a set distance from each original and the delete the original

Here is the basic code for you to play with

Sub guides()

' moves presentation guides 1.5 cm right and down

Dim vpos As Variant

Dim gd As Guide

Dim gd2 As Guide

Dim L As Long

For L = ActivePresentation.guides.Count To 1 Step -1

Set gd = ActivePresentation.guides(L)

vpos = gd.Position

If gd.Orientation = ppHorizontalGuide Then

Set gd2 = ActivePresentation.guides.Add(ppHorizontalGuide, vpos + cm2Points(1.5))

gd.Delete

Else

Set gd2 = ActivePresentation.guides.Add(ppVerticalGuide, vpos + cm2Points(1.5))

gd.Delete

End If

Next L

End Sub

Function cm2Points(inval As Single) As Single

cm2Points = inval * 28.346

End Function

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

Anonymous
2018-05-08T20:45:34+00:00

This would do what you ask but I'm not sure it will solve the problem test carefully on a COPY.

Sub moveMe()

Dim osld As Slide

Dim oshp As Shape

For Each osld In ActivePresentation.Slides

For Each oshp In osld.Shapes

'change amount as required

oshp.Left = oshp.Left + cm2Points(7.195)

Next

Next

End Sub

Function cm2Points(inval As Single) As Single

cm2Points = inval * 28.346

End Function

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2018-06-21T12:44:52+00:00

    Hi John,

    Apologies for the really late reply.

    Thanks this did exactly what I needed it to;  again appreciate your help.

    I modified it to add about 8x vertical and mutiple horizontal guides; all worked well.

    Thanks

    James

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-05-09T17:59:02+00:00

    Hi John,

    Thank you, really appreciate  you taking the time to show me how to do this.  It worked perfectly.

    I've just realised my guides are out now across a few different presentations, is there a code that could move them into position?  (-36, +36H and, 3.2, -3,3 V).

    Thanks again.

    James

    Was this answer helpful?

    0 comments No comments