如何在 Word 样式定义中包含 BackgroundPatternColor 或 HighlightColor?
How to include BackgroundPatternColor or HighlightColor in a Word Style definition?
由于Ms-Office/Word中的Highlight调色板非常有限,在一些Word文档中我们使用BackgroundPatternColor来赋予文本的背景色。
问题:
我想将自定义样式定义为普通样式的衍生样式,其中包括自定义背景颜色。
在样式定义对话框中,我没有找到任何可以包含选区背景色的选项。
有任何想法吗?
注意:唯一接近于此的选项是所谓的边框>阴影>填充颜色,但它始终跨越完整 line/paragraph,不能应用于较少。
通过右键单击并添加背景添加背景颜色
直到有人提出内置答案
像往常一样,我将使用一个解决方法:
对于这种情况,我将使用自定义宏作为自定义样式,并将功能区上的这些宏放入 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
您可以更改背景颜色,但如果您不希望它为整个段落着色,那么您必须创建一个 字符 样式并为其设置颜色 .Font
属性。
(注意:您还可以创建所谓的 "linked" 样式,它可用于段落和字体格式,但这些通常在专业文档圈中不受欢迎。)
这是一个例子
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
由于Ms-Office/Word中的Highlight调色板非常有限,在一些Word文档中我们使用BackgroundPatternColor来赋予文本的背景色。
问题:
我想将自定义样式定义为普通样式的衍生样式,其中包括自定义背景颜色。
在样式定义对话框中,我没有找到任何可以包含选区背景色的选项。
有任何想法吗?
注意:唯一接近于此的选项是所谓的边框>阴影>填充颜色,但它始终跨越完整 line/paragraph,不能应用于较少。
通过右键单击并添加背景添加背景颜色
直到有人提出内置答案
像往常一样,我将使用一个解决方法:
对于这种情况,我将使用自定义宏作为自定义样式,并将功能区上的这些宏放入 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
您可以更改背景颜色,但如果您不希望它为整个段落着色,那么您必须创建一个 字符 样式并为其设置颜色 .Font
属性。
(注意:您还可以创建所谓的 "linked" 样式,它可用于段落和字体格式,但这些通常在专业文档圈中不受欢迎。)
这是一个例子
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