小编Poo*_*kye的帖子

VBA Word:Font.TextColor 和 Font.ColorIndex 之间的区别?

我有一个插入文本的宏。到目前为止,它运行良好,但是...现在对于某些文档,应用颜色时出现错误 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
Run Code Online (Sandbox Code Playgroud)

我注意到,如果我更改“Selection.Font.TextColor = RGB(68, 114, 196)”并将其替换为“Selection.Font.ColorIndex = wdDarkBlue”,它会起作用。因此我的问题是:两者之间有什么区别?为什么有些文档“Textcolor”不起作用?

谢谢 !

vba ms-word

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

ms-word ×1

vba ×1