G
Greg Maxey
This came up in a separate topic and I thought it might be lost in the
weeds. I decided to bring it up here in a dedicated post in hope of
stimulating the discussion.
A group of us discovered quite by accident yesterday that if your delete
something that includes the start of a selection.range then the entire
selection is collapsed. If you delete just part of a selection.range or the
end of a selection.range then the selection is simply resized accordingly.
You can observe this by stepping through the following exercises and
observing the selection:
Sub Experiment1()
Dim oRng1 As Range
Dim oRng2 As Range
Set oRng1 = ActiveDocument.Range
Set oRng2 = ActiveDocument.Range
oRng1.Start = 10
oRng1.End = 20
oRng1.Select
oRng2.Start = 9
oRng2.End = 19
oRng2.Delete 'Selection collapses
End Sub
Sub Experiment2()
Dim oRng1 As Range
Dim oRng2 As Range
Set oRng1 = ActiveDocument.Range
Set oRng2 = ActiveDocument.Range
oRng1.Start = 10
oRng1.End = 20
oRng1.Select
oRng2.Start = 12
oRng2.End = 18
oRng2.Delete 'Selection resizes
End Sub
Sub Experiment3()
Dim oRng1 As Range
Dim oRng2 As Range
Set oRng1 = ActiveDocument.Range
Set oRng2 = ActiveDocument.Range
oRng1.Start = 10
oRng1.End = 20
oRng1.Select
oRng2.Start = 15
oRng2.End = 25
oRng2.Delete 'Selection resizes
End Sub
I am interested in what is happening under the hood in Word that causes the
complete collapse of the selection.range in exercise 1. Thanks
weeds. I decided to bring it up here in a dedicated post in hope of
stimulating the discussion.
A group of us discovered quite by accident yesterday that if your delete
something that includes the start of a selection.range then the entire
selection is collapsed. If you delete just part of a selection.range or the
end of a selection.range then the selection is simply resized accordingly.
You can observe this by stepping through the following exercises and
observing the selection:
Sub Experiment1()
Dim oRng1 As Range
Dim oRng2 As Range
Set oRng1 = ActiveDocument.Range
Set oRng2 = ActiveDocument.Range
oRng1.Start = 10
oRng1.End = 20
oRng1.Select
oRng2.Start = 9
oRng2.End = 19
oRng2.Delete 'Selection collapses
End Sub
Sub Experiment2()
Dim oRng1 As Range
Dim oRng2 As Range
Set oRng1 = ActiveDocument.Range
Set oRng2 = ActiveDocument.Range
oRng1.Start = 10
oRng1.End = 20
oRng1.Select
oRng2.Start = 12
oRng2.End = 18
oRng2.Delete 'Selection resizes
End Sub
Sub Experiment3()
Dim oRng1 As Range
Dim oRng2 As Range
Set oRng1 = ActiveDocument.Range
Set oRng2 = ActiveDocument.Range
oRng1.Start = 10
oRng1.End = 20
oRng1.Select
oRng2.Start = 15
oRng2.End = 25
oRng2.Delete 'Selection resizes
End Sub
I am interested in what is happening under the hood in Word that causes the
complete collapse of the selection.range in exercise 1. Thanks