Thread: [Solved] word 2013 operation on text
View Single Post
 
Old 09-25-2018, 03:43 AM
dogufo dogufo is offline Windows 7 64bit Office 2013
Banned
 
Join Date: Sep 2018
Location: Usa
Posts: 11
dogufo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Try, for example:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[0-9]{1,4} [AB].[DC]."
    .Replacement.Text = ""
    .Forward = True
    .Format = False
    .Wrap = wdFindStop
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If Split(.Text, " ")(1) = "B.C." Then
      .InsertAfter " (chinese year " & Split(.Text, " ")(0) + 2699 & ")"
    ElseIf Split(.Text, " ")(1) = "A.D." Then
      .InsertAfter " (chinese year " & Split(.Text, " ")(0) + 2698 & ")"
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
Note: You'll need to check the correct value to add for B.C. years vs A.D. years, since there was no 0 B.C./A.D.

Thank you very much so this code can be used with python or how to make it work with word 2013? (Sorry, I am not practical )
Reply With Quote