我不知道为什么没有枚举用于设置样式。无论如何,它是形状属性中的第 2 列。所以使用
shp.CellsSRC(visSectionCharacter, 0, 2).FormulaU = 17
将您的文本设置为Bold.
你问我怎么知道这个?基于 Microsoft 的参考了解形状表,有一段有用的代码片段可供使用。
首先,在绘图中选择您想要查看属性信息的形状。然后在 Visio 编辑器中打开“形状属性”窗口(not在 VBE 中)——您可以通过查看开发人员功能区到达那里,然后单击“显示 ShapeSheet”图标
在形状属性窗口中,向下滚动直到看到“字符”部分。您必须选择属性窗口中的单元格之一。此处的示例选择了“样式”列。
完成此操作后,运行下面的代码片段,您将在 VBE 的立即窗口中获得所需的信息。
Public Sub DebugPrintCellProperties()
' Abort if ShapeSheet not selected in the Visio UI
If Not Visio.ActiveWindow.Type = Visio.VisWinTypes.visSheet Then
Exit Sub
End If
Dim cel As Visio.Cell
Set cel = Visio.ActiveWindow.SelectedCell
'Print out some of the cell properties
Debug.Print "Section", cel.Section
Debug.Print "Row", cel.Row
Debug.Print "Column", cel.Column
Debug.Print "Name", cel.Name
Debug.Print "FormulaU", cel.FormulaU
Debug.Print "ResultIU", cel.ResultIU
Debug.Print "ResultStr("""")", cel.ResultStr("")
Debug.Print "Dependents", UBound(cel.Dependents)
' cel.Precedents may cause an error
On Error Resume Next
Debug.Print "Precedents", UBound(cel.Precedents)
Debug.Print "--------------------------------------"
End Sub
这将告诉您调用时要使用的部分、行和列CellsSRC
。我所做的是找出属性,然后我手动将文本设置为粗体并查看结果DebugPrintCellProperties
再次看到FormulaU = 17
为大胆。