Standardize images on same document RRS feed

  • Question

  • Hello everyone, need some help here pls.

    I have this doc with a lot of images. I want to standardize the SIZE (width and height) and the POSITION of all images on the Middle Right of the page.

    I've get this algorithm in another place, then modified it to resize all images to 323x419.

    But how do I make all images stay on the Middle Right of the page?

    Sub pMain() 
      Dim oInShape As Word.InlineShape
      For Each oInShape In ActiveDocument.InlineShapes
        oInShape.LockAspectRatio = msoFalse
        'Ajusta largura da imagem'
        oInShape.Width = 323
        'Ajusta altura da imagem'
        oInShape.Height = 419
        oInShape.LockAspectRatio = msoTrue
      Next oInShape
    End Sub

    Saturday, May 27, 2017 5:01 PM


  • Hi MagnoMedeiros,

    For setting postion, we need convert InlineShape to Shape. So we could use RelativeHorizontalPosition, Left and  WdShapePosition to set the shape's horizontal alignment and  vertical alignment is in the same way. Here is the example

    Sub Test()
    Dim oShape As Word.Shape
    Dim oInShape As Word.InlineShape
    For Each oInShape In ThisDocument.InlineShapes
    oInShape.LockAspectRatio = msoFalse
        oInShape.Width = 323
        oInShape.Height = 419
        oInShape.LockAspectRatio = msoTrue
        'Convert InlineShape to Shape
    Next oInShape
    For Each oShape In ThisDocument.Shapes
    oShape.RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
    oShape.Left = WdShapePosition.wdShapeRight
    oShape.RelativeVerticalPosition = wdRelativeVerticalPositionMargin
    oShape.Top = WdShapePosition.wdShapeCenter
    Next oShape
    End Sub



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Marked as answer by MagnoMedeiros Tuesday, May 30, 2017 6:55 PM
    Monday, May 29, 2017 9:44 AM