How can I divide a shapes outline width in half (/2) using vba?
Myron said:How can I divide a shapes outline width in half (/2) using vba?
Look at Shape.Outline.Width.
So, something like s.Outline.Width = s.Outline.Width/2
If you look at the Object Properties docker, you can see that, when you do that, it is increasing the Outline Width, but also changing the Stretch and Tilt of the nib to get the vertical lines to render at the original outline width. Stretch does not go larger than 100%, so it does it that way.
After you have done that, I don't think the shape has any "memory" of what its old outline width used to be.
If you try going the other way - stretching that rectangle to make it narrower - then you can see that it keeps Outline.Width the same, but changes Stretch and Tilt of the nib to get the thinner vertical lines.
select shape and run macro
Sub Macro1() Dim OrigSelection As ShapeRange, a#, b# Set OrigSelection = ActiveSelectionRange a = OrigSelection(1).Outline.Width b = OrigSelection(1).Outline.NibStretch OrigSelection(1).Outline.Width = a * b / 100 OrigSelection(1).Outline.NibStretch = 100End Sub
previous message edited
Hmmm, closer result but still not 100% accurate.
I'll take it though. Thanks.
difference probably caused by conversion mm(inch) / to pixels