ワードの文章の一桁の数字を全角に、二桁以上の数字を半角に、全角カタカナを半角カタカナに、半角カタカナを全角カタカナに、一括して変換するワードのマクロ |
Sub 一桁の数字を全角二桁以上の数字を半角() Call 半角数字を全角へ一括変換 Call 二桁以上の全角数字を半角へ一括変換 End Sub Sub 半角数字を全角へ一括変換() Dim rng As Range: Set rng = ActiveDocument.Range(0, 0) With rng.Find .Text = "[0-9]" .MatchWildcards = True .MatchFuzzy = False Do While .Execute rng.CharacterWidth = wdWidthFullWidth rng.Collapse wdCollapseEnd Loop End With Set rng = Nothing End Sub Sub 二桁以上の全角数字を半角へ一括変換() Dim rng As Range: Set rng = ActiveDocument.Range(0, 0) With rng.Find .Text = "[0-9]{2,}" .MatchWildcards = True .MatchFuzzy = False Do While .Execute rng.CharacterWidth = wdWidthHalfWidth rng.Collapse wdCollapseEnd Loop End With Set rng = Nothing End Sub Sub 全角カタカナを半角カタカナに変換() Selection.WholeStory Selection.Find.ClearFormatting With Selection.Find .Text = "[ア-ヾ]" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchFuzzy = False .MatchWildcards = True End With Selection.Range.CharacterWidth = wdWidthHalfWidth End Sub Sub 半角カタカナを全角カタカナに変換() Selection.WholeStory Selection.Find.ClearFormatting With Selection.Find .Text = "[ヲ-゚]" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchFuzzy = False .MatchWildcards = True End With Selection.Range.CharacterWidth = wdWidthFullWidth End Sub |
|