You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 17:10:37