
word
我刚写了个
word宏,专门用来把文档里的数字设成上标,效果挺不错的,分享给大家看看:
VBASub shangbiao() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = ^ '查找所有数字 .Replacement.Text = ^^&' With .Replacement.Font' .Superscript = True' .Subscript = False' End With Selection.Font.Superscript = True .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWhole
word = False .MatchByte = True .MatchWildcards = False .MatchSoundsLike = False .MatchAll
wordForms = False End With Selection.Find.Execute Replace:=wdReplaceAllEnd Sub
这个宏的思路就是用通配符^来匹配所有数字,然后替换成同样的内容,并把这部分字体设置成上标。目前注释掉的那一段是原本打算用来设置字体样式的,不过我发现直接设置Selection.Font.Superscript = True更简单粗暴,效果也不错。大家如果在用word处理文献引用、脚注啥的,这个宏应该挺实用的。如果你有啥优化建议,或者发现啥bug,欢迎留言交流哈~