'如果对大量word文档进行修改,可以用这个代码,让年月日落款放在一行。
Sub 年月日同行()
Dim l1, l2, s
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "<[0-9 ]@年[0-9 ]@月[0-9 ]@日^13"
.MatchWildcards = True
.Wrap = wdFindContinue
.Forward = True
.Execute
End With
If Selection.Find.Found = True Then
s = Selection.ParagraphFormat.CharacterUnitFirstLineIndent '首行缩进字数
l1 = Selection.Information(wdFirstCharacterLineNumber) '获取当前页行数
Selection.EndKey
l2 = Selection.Information(wdFirstCharacterLineNumber) '获取当前页行数
Do While l2 > l1
If s > 2 Then
Selection.MoveUp Unit:=wdLine, count:=1 '向上一行
Selection.ParagraphFormat.CharacterUnitFirstLineIndent = s - 2 '首行缩进减少2字