Created
July 15, 2025 08:11
-
-
Save monokano/c859ace700294580375210b85913acdf to your computer and use it in GitHub Desktop.
docxの数式エディタの箇所に淡いピンクの背景色を付けるマクロ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sub 数式エディタの背景を淡いピンクに() | |
| Dim oField As Field | |
| Dim oRange As Range | |
| Dim oMath As oMath | |
| Dim count As Integer | |
| count = 0 | |
| ' 古い形式の数式フィールドをチェック | |
| For Each oField In ActiveDocument.Fields | |
| If oField.Type = wdFieldExpression Then | |
| Set oRange = oField.Result | |
| ' さらに淡いピンク背景 | |
| With oRange.Shading | |
| .Texture = wdTextureNone | |
| .BackgroundPatternColor = RGB(255, 230, 225) ' さらに淡いピンク | |
| End With | |
| ' ピンクの囲み罫 | |
| With oRange.Borders | |
| .Enable = True | |
| .OutsideLineStyle = wdLineStyleDot | |
| .OutsideColor = wdColorPink | |
| End With | |
| count = count + 1 | |
| End If | |
| Next oField | |
| ' 新しい数式エディタ(OMath)をチェック | |
| For Each oMath In ActiveDocument.OMaths | |
| ' さらに淡いピンク背景 | |
| With oMath.Range.Shading | |
| .Texture = wdTextureNone | |
| .BackgroundPatternColor = RGB(255, 230, 225) ' さらに淡いピンク | |
| End With | |
| ' ピンクの囲み罫 | |
| With oMath.Range.Borders | |
| .Enable = True | |
| .OutsideLineStyle = wdLineStyleDot | |
| .OutsideColor = wdColorPink | |
| End With | |
| count = count + 1 | |
| Next oMath | |
| ' 結果を報告 | |
| If count > 0 Then | |
| MsgBox count & "個の数式にピンクの罫線と淡いピンク背景を適用しました!", vbInformation | |
| Else | |
| MsgBox "数式が見つかりませんでした。数式エディタで入力した数式があるか確認してください。", vbExclamation | |
| End If | |
| End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment