|
-
Oct 11th, 2000, 12:42 AM
#1
Thread Starter
New Member
Below is some code writen for the purpose of learning more about Word VBA. This code eliminates consecutive identical paragraphs -- but it is ugly code. How can I cut this down, by identifying the two paragraphs in the If statement? Please help. Thanks.
Sub Macro1()
Selection.HomeKey Unit:=wdStory
For i = 1 To ActiveDocument.Paragraphs.Count - 1
Selection.Paragraphs(1).Range.Select
Nextpara = Selection.Paragraphs(1).Next
If Selection = Nextpara Then
'Why can't this line incorporate the above two lines? Help!
Selection.Delete
Else
Selection.MoveDown Unit:=wdParagraph
End If
Next i
End Sub
-
Oct 11th, 2000, 01:11 AM
#2
Lively Member
well I took a shot at it - see if it works
Code:
Sub Macro1()
Dim i As Integer
Selection.HomeKey Unit:=wdStory
i = 1
Do While i < ActiveDocument.Paragraphs.Count
Selection.Paragraphs(i).Range.Select
Nextpara = Selection.Paragraphs(i).Next
If Selection = Nextpara Then
Selection.Delete
Else
i = i + 1
End If
Loop
End Sub
-
Oct 11th, 2000, 01:16 AM
#3
Addicted Member
what do you mean exactly?
something like this:
Code:
Sub Macro1()
Selection.HomeKey Unit:=wdStory
For i = 1 To ActiveDocument.Paragraphs.Count - 1
If Selection.Paragraphs(1).Range.Select = Selection.Paragraphs(1).Next Then
Selection.Delete
Else
Selection.MoveDown Unit:=wdParagraph
End If
Next i
End Sub
-
Oct 12th, 2000, 01:43 AM
#4
Addicted Member
what exactly do you want to archieve? The code you posted is working fine, so what is the problem?
please let me know?
-
Oct 12th, 2000, 09:10 AM
#5
Thread Starter
New Member
No Solution Found yet
The above attempts either don't work or don't address the problem. I need the if statement to identify the subject paragraph and the following. HELP!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|