西暦(昨年)を和暦(今年)に変更する | カメレオンのVBA

カメレオンのVBA

VBAの私的メモ書き

    With ActiveDocument.Content.Find
        .Text = (Year(Date) - 1) & "年"  '西暦で昨年を指している部分を探す
        .Format = True  '検索・置換をする
        With .Replacement
            .Text = Format(Date, "ggge年") '和暦
            .Font.Bold = True  '太字にします
        End With
        .Execute Replace:=wdReplaceAll
    End With