G
Greg Maxey
Hello,
As an example, I want to remove all text except the first character in each
paragraph.
I can use:
Sub Test()
Dim oPara As Paragraph
Dim oDoc As Document
Set oDoc = ActiveDocument
For Each oPara In oDoc.Paragraphs
With oPara.Range
.MoveEnd wdCharacter, -1
.MoveStart wdCharacter, 1
.Delete
End With
Next
End Sub
Now why is it that the following removes everything from the document? By
excluding the With statement is the oPara.Range reset to its orginal value
each time it is restated? Thanks.
Sub Test1()
Dim oPara As Paragraph
Dim rngPara As Range
Dim oDoc As Document
Dim i As Long
Set oDoc = ActiveDocument
For Each oPara In oDoc.Paragraphs
oPara.Range.MoveEnd wdCharacter, -1
oPara.Range.MoveStart wdCharacter, 1
oPara.Range.Delete
Next
End Sub
As an example, I want to remove all text except the first character in each
paragraph.
I can use:
Sub Test()
Dim oPara As Paragraph
Dim oDoc As Document
Set oDoc = ActiveDocument
For Each oPara In oDoc.Paragraphs
With oPara.Range
.MoveEnd wdCharacter, -1
.MoveStart wdCharacter, 1
.Delete
End With
Next
End Sub
Now why is it that the following removes everything from the document? By
excluding the With statement is the oPara.Range reset to its orginal value
each time it is restated? Thanks.
Sub Test1()
Dim oPara As Paragraph
Dim rngPara As Range
Dim oDoc As Document
Dim i As Long
Set oDoc = ActiveDocument
For Each oPara In oDoc.Paragraphs
oPara.Range.MoveEnd wdCharacter, -1
oPara.Range.MoveStart wdCharacter, 1
oPara.Range.Delete
Next
End Sub