|
可试试如下代码的效果(默认初始化方法,并非指定)
- Sub test()
- '用拼音指南对全文档或选定区域加注拼音并修改相关格式参数
- Dim myRange As Range
- Dim aSentence As Range
-
- Application.ScreenUpdating = False
- Set myRange = IIf(Selection.Type = wdSelectionIP, ActiveDocument.Content, Selection.Range)
- ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
- For Each aSentence In myRange.Sentences
- If aSentence.Text Like "*[一-龥]*" Then
- aSentence.Select
- Dialogs(986).Show 1 'FormatPhoneticGuide
- End If
- Next
-
- '以下代码可用于调整拼音文本格式参数,可按需选择使用(实为修改EQ域代码)
- ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
- With myRange.Find
- .Execute findtext:="\* jc^# ", replacewith:="\* jc0 ", Replace:=2 '对齐,0为居中,自行查看数值与对齐方式的关系
- .Execute findtext:="""Font:宋体""", replacewith:="""Microsoft YaHei UI""", Replace:=2 '仅修改EQ域中字体名称
- ' .Execute findtext:="\* hps^# ", replacewith:="\* hps8 ", Replace:=2 '偏移量,假设原为一位数
- ' .Execute findtext:="\up ^#^#(", replacewith:="\up 12(", Replace:=2 '拼音与汉字间距,假设原为两位数
- '以下查找代码用于修改拼音字体大小及名称
- .Text = "\up ^#"
- Do While .Execute
- With .Parent
- .SetRange .End + .MoveEndUntil("("), .End + .MoveEndUntil(")") - 1 '定位拼音字符
- .Font.Size = 8 '修改字体大小
- .Font.Name = "Microsoft YaHei UI '修改字体名称"
- .Collapse 0
- End With
- Loop
- End With
- ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|