Formatting Shapes

Viewed 34

I'm trying to build some automation with Excel and Word, I'm making Judô diplomas in Word by taking the information in Excel and dropping in the doc.

My doubt is about how would I script to change the color of a shape/border? I tried to record my steps but word seems to be unnable to do it and didn't record anything, can somebody help me?

This image below is in portuguese:

enter image description here

1 Answers

This example recolors all shapes in the active document. You probably need to change the color on one particular shape. Therefore, before changing the color of the lines, you must first select the desired shape, focusing on some signs.

Sub ShapesColors()
    Dim doc As Document, sh As Shape
    Set doc = ActiveDocument
    
    For Each sh In doc.Shapes
        With sh.Line
            .Weight = 3
            .ForeColor = vbMagenta
        End With
        sh.Fill.ForeColor = vbWhite
    Next
End Sub

Before enter image description here

After enter image description here

Related