In MS Word I draw rectangle as Autoshape with Win32com, but I can't understand how to change its colors with FillFormat.

word = win32com.client.gencache.EnsureDispatch('Word.Application')
document = word.ActiveDocument
rect = shapes.AddShape(1, 56.7, 14.2, 524.4, 813.5)

By default it provides solid blue figure. What I need is transparent rectangle with black thick border.

1 Answers

0
Cindy Meister On Best Solutions

"Thick border" is not an exact parameter, but based on the assumption that the default border is already "thick", the following sample VBA code illustrates how to remove the fill and change the color of the border:

rect.Fill.Visible = 0  'msoFalse
rect.Line.ForeColor.RGB = RGB(0, 0, 0)

I don't use Python, but it appears from the code in the question to work with the object model the same way VBA does, once it has the connection to the Word application and a Document object...