Sub EquationSpacer() ' Paul Beverley - Version 06.12.22 ' Adds spaces either side of equations that butt up to some text myEEColour = wdYellow doHighlight = True myTrack = ActiveDocument.TrackRevisions ActiveDocument.TrackRevisions = False numMaths = ActiveDocument.InlineShapes.count If numMaths > 0 = True Then For Each myMath In ActiveDocument.InlineShapes Set rng = myMath.Range.Duplicate myColour = myMath.Range.HighlightColorIndex myEnd = rng.End myStart = rng.Start rng.Start = myEnd rng.End = myEnd + 1 myText = rng.Text ' Look at what follows the equation If LCase(myText) <> UCase(myText) Then rng.InsertBefore Text:=ChrW(32) rng.Font.Color = wdColorPink rng.Start = rng.Start - 1 rng.HighlightColorIndex = wdNoHighlight myMath.Range.HighlightColorIndex = myColour spacesAdded = spacesAdded + 1 End If rng.Start = myStart - 1 rng.End = myStart myText = rng.Text ' Look at what precedes the equation If LCase(myText) <> UCase(myText) Or myText = "." Or myText = "," Then rng.InsertAfter Text:=ChrW(32) rng.Font.Color = wdColorPink spacesAdded = spacesAdded + 1 End If Next myMath End If numEqns = ActiveDocument.OMaths.count eeSpacesAdded = 0 If numEqns > 0 Then Set rng = ActiveDocument.Content For Each myMath In ActiveDocument.OMaths Set rngMath = myMath.Range.Duplicate rng.End = rngMath.Start rng.Start = rng.End - 1 If LCase(rng) <> UCase(rng) Then rng.Text = rng.Text & " " If doHighlight = True Then rng.HighlightColorIndex = myEEColour eeSpacesAdded = eeSpacesAdded + 1 End If rng.End = rngMath.End + 1 rng.Start = rng.End - 1 If LCase(rng) <> UCase(rng) Then rng.Text = " " & rng.Text If doHighlight = True Then rng.HighlightColorIndex = myEEColour eeSpacesAdded = eeSpacesAdded + 1 End If DoEvents Next myMath End If ActiveDocument.TrackRevisions = myTrack myMsg = vbCr If spacesAdded > 0 Then myMsg = spacesAdded & " spaces added to MathType equations" & vbCr & myMsg If eeSpacesAdded > 0 Then myMsg = eeSpacesAdded & " spaces added to Equation Editor equations" & vbCr & myMsg MsgBox myMsg End Sub