|
不知kqbt用什么程序。14楼的代码好像可以处理。
如将代码再修改一下,好像还可以处理只有月日没有年份,或年份只用“去年”之类表示的日期。可试试:
Sub FormatDate3()
Const strA As String = "[〇○一二三四五六七八九十]@"
Const strB As String = "00123456789"
Dim temp As String, i As Byte
Application.ScreenUpdating = False
With ActiveDocument.Content.Find
.MatchWildcards = True
.Text = "[〇○一二三四五六七八九十年]@" & "月" & strA & "日"
Do While .Execute
With .Parent
If .Text Like "年*" Then .Start = .Start + 1
temp = Replace(.Text, "年", "-")
temp = Replace(temp, "月", "-")
temp = Replace(temp, "日", "")
For i = 1 To 11
temp = Replace(temp, Mid(strA, i + 1, 1), Mid(strB, i, 1))
Next
temp = Replace(temp, "-十-", "-10-")
If temp Like "*-十" Then temp = Left(temp, Len(temp) - 1) & Replace(temp, "十", "10", Len(temp))
If temp Like "*十" Then temp = Left(temp, Len(temp) - 1) & Replace(temp, "十", "0", Len(temp))
If temp Like "十-*" Then temp = Replace(temp, "十", "10", 1, 1)
If temp Like "十?-*" Then temp = Replace(temp, "十", "1", 1, 1)
temp = Replace(temp, "-十", "-1")
temp = Replace(temp, "十", "")
If InStr(.Text, "年") Then .Text = Format(temp, "yyyy年M月d日") Else .Text = Format(temp, "M月d日")
.Collapse wdCollapseEnd
End With
Loop
End With
Application.ScreenUpdating = True
End Sub |
|