在C#VSTO中更改Excel注释字体
这可能看起来很微不足道,但对我来说,我不知道如何改变评论框的字体属性。 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;
你可以在这里看到Characters类的所有成员。