如果文档中的代码表格时,感觉还是很快速有用的。
Sub HangHao() ' ' hanghao 宏 ' ' Dim parag As Paragraph Dim nLineNum: nLineNum = 0 Dim selRge As Range Set selRge = Selection.Range For Each parag In Selection.Paragraphs nLineNum = nLineNum + 1 bgNLineNum = nLineNum selRge.Paragraphs(nLineNum).Range.InsertBefore (Format$(bgNLineNum, "00") & " ") Next ' 背景色为morning的配色方案,RGB为(229,229,229) With Selection.Tables(1) With .Shading .Texture = wdTextureNone .ForegroundPatternColor = wdColorAutomatic .BackgroundPatternColor = 15066597 '15066597这个数其实就是229*(2^16 + 2^8 + 1) End With Options.DefaultHighlightColorIndex = wdNoHighlight 'NeXT_Jobs新增的:清除“以不同颜色突出显示文本”,从而解决从VS中“保留源格式”复制带来的文本高亮问题 Selection.Range.HighlightColorIndex = wdNoHighlight 'NeXT_Jobs新增的:清除“以不同颜色突出显示文本”