Macro will not End at bottom off the Document

S

Steved

Hello from Steved

The Macro finds the next first line By Identifing the
font size 30 and Bold, which is what it does, however
when it reaches the bottom of the document it then
deletes everthing above until it reaches the top of the
document. I goto debug it and it is highlighting
With Selection.Find.Font

Where in the Macro Can I put in telling it when it
reaches the bottom it stops.

Thanks in advance

Sub RaceDictionary2()
Dim i As Long
For i = 1 To ActiveDocument.Paragraphs.Count
With Selection.Find
.Text = "<[A-Za-z]@>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Extend
Selection.HomeKey Unit:=wdLine
Selection.Delete Unit:=wdCharacter, Count:=1
With Selection.Find.Font
.Size = 30
.Bold = True
End With
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.Find.Execute
End With
Next i
End Sub
 
J

Jezebel

We answered this one several times three weeks ago, Steved. Didn't you like
the answers you got then?
 
S

Steved

Hello from Steved

Firstly yes I did like thje answer I got three weeks ago
and applied the solution I was given. I rewrote the macro
to try and find the problem which was not completely
solved, hence since then i.ve been trying to learn more
about macros. If I knew a place I could goto and find out
how to do loops I would be fine. ie the example below, I
would like to goto a site that would explain what each
line does, then and only then I would be able to put
together macro loops. So with this in mind the macro
would read the first line of each paragraph until the end
of the document. believe me it is so simple but I've not
been able to put my head around it.

Dim i As Long
For i = 1 To ActiveDocument.Paragraphs.Count
End With
Next i


I should finish by saying this is a little project off my
own, and this is why I've come to this site for help, as
I do not use macros normally in word.

Thankyou

-----Original Message-----
We answered this one several times three weeks ago, Steved. Didn't you like
the answers you got then?



Hello from Steved

The Macro finds the next first line By Identifing the
font size 30 and Bold, which is what it does, however
when it reaches the bottom of the document it then
deletes everthing above until it reaches the top of the
document. I goto debug it and it is highlighting
With Selection.Find.Font

Where in the Macro Can I put in telling it when it
reaches the bottom it stops.

Thanks in advance

Sub RaceDictionary2()
Dim i As Long
For i = 1 To ActiveDocument.Paragraphs.Count
With Selection.Find
.Text = "<[A-Za-z]@>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Extend
Selection.HomeKey Unit:=wdLine
Selection.Delete Unit:=wdCharacter, Count:=1
With Selection.Find.Font
.Size = 30
.Bold = True
End With
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.Find.Execute
End With
Next i
End Sub


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top