在 C# VSTO 中更改 Excel 注释字体

Change Excel Comment Font in C# VSTO

这可能看起来很微不足道,但对于我来说,我无法弄清楚如何更改评论框的字体属性。 VBA 代码示例为:

Sub SetCommentsProperties()
Dim Cell As Range
For Each Cell In Selection
If Not Cell.Comment Is Nothing Then
With Cell.Comment.Shape.TextFrame.Characters.Font
.ColorIndex = 3
.Size = 12
.Name = "Arial Black"
End With
End If
Next Cell
End Sub

然而,在 C# VSTO 中,我只能达到

Cell.Comment.Shape.TextFrame.Characters()

这对我有用:

var selection = Globals.ThisAddIn.Application.Selection as Range;
var textFrame = selection.Comment.Shape.TextFrame;
textFrame.Characters().Font.ColorIndex = 3;
textFrame.Characters().Font.Size = 30;

您可以看到角色classhere.

的所有成员