R
RB Smissaert
Trying to do the following:
Check the character after a range variable and if this is a space then
delete that range plus the space character after it.
I am not used to Word VBA and eventually I came up with this code that
works, but it seems there must be a simpler way:
Dim oRangeDup As Range
If vStringNilFound = -1 Then
Set oRangeDup = oRange.Duplicate
oRangeDup.Collapse wdCollapseEnd
oRangeDup.Expand wdCharacter
If oRangeDup.Text = " " Then
oRange.Expand wdWord
oRange.Delete
End If
Else
oRange.Text = vStringNilFound
End If
I need to leave the oRange variable intact if there is no space after that
oRange, so I can't collapse that
oRange.
Any suggestion what the normal way is to do this?
RBS
Check the character after a range variable and if this is a space then
delete that range plus the space character after it.
I am not used to Word VBA and eventually I came up with this code that
works, but it seems there must be a simpler way:
Dim oRangeDup As Range
If vStringNilFound = -1 Then
Set oRangeDup = oRange.Duplicate
oRangeDup.Collapse wdCollapseEnd
oRangeDup.Expand wdCharacter
If oRangeDup.Text = " " Then
oRange.Expand wdWord
oRange.Delete
End If
Else
oRange.Text = vStringNilFound
End If
I need to leave the oRange variable intact if there is no space after that
oRange, so I can't collapse that
oRange.
Any suggestion what the normal way is to do this?
RBS