How can I move a bunch of textframes in VBA in MS Publisher?

118 Views Asked by At

Is there an easy method which could change the position (horizontal and vertical) of lots of textframes in MS Publisher? And where can I find all the methods with explanations for programming Macros?

1

There are 1 best solutions below

0
Jbjstam On

The Publisher object model is available here: https://msdn.microsoft.com/en-us/library/office/ff939040.aspx .

Information about the VBA editor (which works the same in Publisher as in Word or Excel), is available here: https://support.office.com/en-us/article/Find-Help-on-using-the-Visual-Basic-Editor-61404b99-84af-4aa3-b1ca-465bc4f45432

This moves all selected shapes 2 cm downwards and 3 cm rightwards:

Option Explicit

Sub MoveTextFrames()
    Dim oShapes As ShapeRange
    Dim oShape As Shape
    Dim moveRight As Long
    Dim moveDown As Long

    moveRight = 3
    moveDown = 2

    Set oShapes = Selection.ShapeRange

    For Each oShape In oShapes
        oShape.Left = oShape.Left + CentimetersToPoints(moveRight)
        oShape.Top = oShape.Top + CentimetersToPoints(moveDown)
    Next oShape

End Sub

Just edit these lines if you want some other values:

    moveRight = 3
    moveDown = 2