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

最新版Visio是否支持通过VBA修改组织结构图下属布局?

在最新版Visio中通过VBA修改组织结构图下属布局

最新版Visio支持通过VBA程序化修改组织结构图的下属布局,相比旧版调用OrgC11加载项的方式(如Call Visio.Application.Addons("OrgC11").Run("/toolbar_vert")),现在可以直接通过Shape对象的Layout属性实现,这种方式更灵活可控。

示例VBA代码

Sub ChangeSubordinateLayout()
    Dim orgChart As Visio.Document
    Set orgChart = Application.ActiveDocument

    Dim orgChartPage As Visio.Page
    Set orgChartPage = orgChart.Pages(1)

    Dim topLevelShape As Visio.Shape
    Set topLevelShape = orgChartPage.Shapes.ItemFromID(1)

    Dim subordinates As Visio.Shapes
    Set subordinates = topLevelShape.Subordinates

    Dim subordinateShape As Visio.Shape
    For Each subordinateShape In subordinates
        subordinateShape.Layout = VisLayoutTypes.visLORL
    Next subordinateShape
End Sub

代码说明

  • 代码默认当前活动文档的第一页为组织结构图,且顶层形状的ID为1,可根据实际场景调整参数
  • 通过topLevelShape.Subordinates获取顶层形状的所有下属节点
  • 将下属形状的Layout属性设置为VisLayoutTypes.visLORL(水平树形结构),你可以替换为其他VisLayoutTypes枚举值实现不同布局:
    • visLOBL:从上到下的垂直树形布局
    • visLOBR:从下到上的垂直树形布局
    • visLORR:从右到左的水平树形布局

内容的提问来源于stack exchange,提问作者Brady Guy

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 06:34:58