【发布时间】:2017-08-01 09:40:57
【问题描述】:
我正在使用这样的代码将每个部分的所有页眉/页脚输出到文本文件: Word VBA - getting text file output to look right
我已经能够使用 Replace() 毫无问题地转换 sHeader/sFooter 字符串变量中的所有特殊字符。
例如:sFooter = Replace(sFooter, ChrW(8804), "^R'\ {\uc2\u8804 <=}'")
在我尝试替换上标之前,一切都很好。 Alt+x 只给了我字母本身的值。我试过查找十六进制值(甚至可能不是一件事)但没有成功。我什至尝试过不同的拉丁字符值。
我录制了一个宏,看看 Word 将如何替换它并得到:
Selection.Find.ClearFormatting
With Selection.Find.Font
.Superscript = True
.Subscript = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "A"
.Replacement.Text = "^super{a}"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
问题是我不知道如何一起使用它们。
我尝试使用oSec.Footers(wdHeaderFooterFirstPage).Range.Find... 而不是Selection.Find...,但这会产生一个空字符串。
我可以从 sHeader/sFooter 以某种方式创建一个 String 对象,以便我可以使用记录的宏代码吗?我尝试谷歌搜索,将字符串转换为对象,但没有得到任何帮助。有更好的方法吗?
提前致谢。
【问题讨论】: