Delete Any Space Found At End Of Range
I'm really struggling to try and get a sub to delete any trailing space that it finds within a content control range. I've looked across the internet and can find plenty to help trim trailing spaces within a cell for Excel, but nothing for Word (or at least I cannot find anything).
This sub will need to work within a UserForm / Macro Enabled Template environment.
There is only usually a single space that needs deleting (occasionally two), but this sub will be called to run across numerous Content Controls.
I'm not sure whether it would be prudent to try and cover all the various different forms of space, such as non breaking etc.
Here is what I have at the moment.
Code:
Private Sub DeleteTrailingSpace(cCtrl As ContentControl)
Dim oRng As Range
With cCtrl.Range
Set oRng = cCtrl.Range
' If the last character is a space then delete it
If oRng.Characters.Last = Chr(32) Then
oRng.Characters.Last.Delete
ElseIf oRng.Characters.Last <> Chr(32) Then
End If
End With
lbl_Exit:
Exit Sub
Hoping someone can help. Thanks!