段落を黒枠で囲む【素人 Word マクロ】
Microsoft officeのWordVBAでマクロを組みましたので公開します。
インターネットで検索したり、マクロの記録機能を使ったり、AIに考えてもらったりしたのを組み合わせだけなので、上手くはないですが、一応動くはずです。
office2021です。
必ず、元データのバックアップを取ってから実行してください。
素人の作ったものなので、信用しすぎないでください。
[仕様]
カーソルのある段落を長方形に囲みます。
[コード]
Sub 段落を四角で囲む()
Dim currentRange As Range
Dim paraFormat As ParagraphFormat
' カーソルのある行を取得
Set currentRange = Selection.Paragraphs(1).Range
currentRange.End = currentRange.End - 1 ' 行末の段落記号を除外
' 段落の外枠を黒に設定
Set paraFormat = currentRange.ParagraphFormat
With paraFormat.Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorBlack
End With
With paraFormat.Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorBlack
End With
With paraFormat.Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorBlack
End With
With paraFormat.Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorBlack
End With
End Sub
この記事が気に入ったらサポートをしてみませんか?