Visio VBA:如何将组织结构图中的所有文本设为粗体

Visio VBA: How to make all text in Org Chart Bold

我想简化在 Visio 中更新我的组织结构图的过程。到目前为止,我有一个从这里 https://bvisual.net/2010/01/28/applying-selected-datagraphic-to-the-whole-document/ 借来的宏并写在下面。我想对其进行调整以对具有形状的文本格式进行一些更改,例如使字体变粗并可能改变它的颜色。我发现很难在网上找到这样的例子,所以任何 help/suggestion 将不胜感激。

 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

您可以修改默认的 OrgChart 形状,尽管它不受官方支持。要更改默认形状(将其字体设为粗体),您需要编辑这些 OrgChart 形状的模板(母版)。在同一博客中,您可以在此处找到有关自定义 OrgChart 图表的更多信息:https://bvisual.net/2012/05/08/creating-a-custom-org-chart-template-with-extra-properties

过程基本相同,只是没有添加属性,而是将文本设为粗体。