Visio VBA: 如何使所有的文本在组织结构图中的粗体

问题描述 投票:0回答:1

我想在Visio中简化更新我的orgcharts。 到目前为止,我有一个从这里借来的宏。https:/bvisual.net20100128applying-selected-datagraphic-to-the-whole-document。 并写在下面。 我想对它进行调整,对文字的格式和形状做一些改变,例如,使字体变粗,并有可能改变它的颜色。 我发现在网上很难找到这样的例子,所以非常感谢任何帮助建议。

 Public Sub ApplyDataGraphicToDocument()
    Dim mstDG As Visio.Master
    Dim shp As Visio.Shape
    Dim pag As Visio.Page
    Dim firstProp As String

       If Visio.ActiveWindow.Selection.Count = 0 Then
           MsgBox "Please select a shape which already has data graphics"
           Exit Sub
       Else
           Set shp = Visio.ActiveWindow.Selection.PrimaryItem
          If shp.DataGraphic Is Nothing Then
               MsgBox "Please select a shape which already has data graphics"
              Exit Sub
           Else
              'Get the shapes DataGraphic master
              Set mstDG = shp.DataGraphic
               'Get the name of the first Shape Data row
              firstProp = "Prop." & _
 shp.CellsSRC(Visio.visSectionProp, 0, 0).RowNameU
           End If
      End If

       For Each pag In Visio.ActiveDocument.Pages
           If pag.Type = visTypeForeground Then
               For Each shp In pag.Shapes
           'Check that the named Shape Data row exists
                  If shp.CellExistsU(firstProp, Visio.visExistsAnywhere) Then
                      'Set the DataGraphic
                      shp.DataGraphic = mstDG
                                       End If
              Next
          End If
      Next

  End Sub

vba formatting visio
1个回答
1
投票

你可以修改默认的OrgChart形状,虽然是 未正式支持. 要改变默认形状(使其字体变粗),你需要编辑这些OrgChart形状的模板(母版)。在同一个博客中,你可以找到更多关于自定义OrgChart图表的信息,这里。https:/bvisual.net20120508creating-a-custom-org-chart-templatewith-extra-properties。

程序大体相同,只是不加属性,而是让文字加粗。

© www.soinside.com 2019 - 2024. All rights reserved.