如何用VBA修改Word中形状的MsoLineJoinStyle?
解决Word 2016 VBA中矩形线条连接样式的修改问题
Word VBA的LineFormat对象确实没有JoinStyle属性,线条连接样式的设置需要直接操作Shape对象的**LineJoinStyle**属性。
可用的线条连接样式常量
msoLineJoinBevel: 斜角连接msoLineJoinRound: 圆角连接msoLineJoinMiter: 尖角连接(默认值)
修改后的代码示例
Dim leftPos As Single, topPos As Single, shapeWidth As Single, shapeHeight As Single ' 自行设置位置和尺寸参数 leftPos = 100 topPos = 100 shapeWidth = 200 shapeHeight = 150 With ActiveDocument.Shapes.AddShape(msoShapeRectangle, leftPos, topPos, shapeWidth, shapeHeight) .Line.Weight = 11 .Line.ForeColor.RGB = RGB(32, 56, 100) .Line.Style = msoLineSingle ' 设置线条连接样式为斜角 .LineJoinStyle = msoLineJoinBevel End With
说明
这个属性直接作用于Shape对象,设置后矩形的四个角线条连接样式会立即生效,适配Word 2016及更高版本的VBA环境。
内容的提问来源于stack exchange,提问作者leen
相关产品推荐
相关产品推荐

