由于 Ms-Office/Word 中的 Highlight 调色板非常有限,在一些 Word 文档中我们使用 BackgroundPatternColor 来赋予文本的背景颜色。
问题:
我想将自定义样式定义为普通样式的衍生产品,其中包括自定义背景颜色。
在样式定义对话框中,我没有找到任何可以包含选择的 bgcolor 的选项。有任何想法吗?
注意:唯一接近的选项是所谓的边框>阴影>填充颜色,但始终跨越整行/段落,不能应用于更少。
由于 Ms-Office/Word 中的 Highlight 调色板非常有限,在一些 Word 文档中我们使用 BackgroundPatternColor 来赋予文本的背景颜色。
问题:
我想将自定义样式定义为普通样式的衍生产品,其中包括自定义背景颜色。
在样式定义对话框中,我没有找到任何可以包含选择的 bgcolor 的选项。有任何想法吗?
注意:唯一接近的选项是所谓的边框>阴影>填充颜色,但始终跨越整行/段落,不能应用于更少。
您可以更改背景颜色,但如果您不希望它为整个段落着色,则必须创建字符样式并为其.Font
属性设置颜色。
(注意:您也可以创建一个所谓的“链接”样式,它可以用于段落和字体格式,但这些在专业文档圈子中通常是不受欢迎的。)
这是一个例子
Sub ChangeStyleColor()
Dim styl As word.style
Dim stylName As String
Dim color As word.WdColor
stylName = "fontBlueBackground"
color = wdColorAqua
' the style might not exist - if not, create it
On Error Resume Next
Set styl = ActiveDocument.styles(stylName)
On Error GoTo 0
If styl Is Nothing Then
Set styl = ActiveDocument.styles.Add(stylName, word.WdStyleType.wdStyleTypeCharacter)
styl.BaseStyle = word.WdBuiltinStyle.wdStyleDefaultParagraphFont
End If
CharStyleBackgroundColor styl, color
End Sub
Sub CharStyleBackgroundColor(styl As word.style, color As word.WdColor)
styl.Font.Shading.BackgroundPatternColor = color
End Sub
在有人像往常一样 提出内置答案之前,我将使用一种解决方法:
对于这种情况,我将使用自定义宏作为自定义样式,并将这些宏放在功能区上的 m-styles 文件夹中。
例如:
Sub F_HáttérSzín_Hupilila()
Dim SzínKód As Variant
SzínKód = 13444920
Selection.Font.Shading.BackgroundPatternColor = SzínKód
End Sub
通过右键单击并添加背景添加背景颜色