我有一个插入文本的宏,一直以来都运行良好,但是现在在某些文档中,当应用颜色时会出现错误445。
以下是代码:
'Some code before that insert a first page with a different section and writes into the header
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.TypeParagraph
With Selection.Font
.Name = "Calibri"
.Size = 14
.Bold = True
.Italic = False
.TextColor = RGB(68, 114, 196)
End With
With Selection.ParagraphFormat
.Alignment = wdAlignParagraphCenter
.SpaceAfter = 6
End With
Selection.TypeText Text:="eReference file for work order: "
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="workorder"
Selection.TypeParagraph
我注意到如果我更改 "Selection.Font.TextColor = RGB (68, 114, 196)" 并替换为 "Selection.Font.ColorIndex = wdDarkBlue",它可以正常工作。因此我的问题是:这两者之间有什么区别?为什么在某些文档中“TextColor”无法正常工作?
谢谢!
Font.ColorIndex = RGB(68, 114, 196)
就会把颜色设置为 RGB(64, 114, 196) 吗?还是仅仅不会崩溃?因为根据WdColorIndex
枚举类型的性质,我非常怀疑将其分配给 RGB 值会得到你所要的颜色。虽然我可能错了——我对 Word 对象模型不是很熟悉。 - Mathieu GuindonSelection
。我只是不知道如何在不使用它的情况下设置颜色。 - Pookye