R
RPMitchal
Wood 2003
In an effort to begin the learning process of VBA I am attempting to create
some uncomplicated macros which hopefully apply to any document with which I
am actively involved. However, I am finding that thus far even the most
rudimentary and simplest of the VBA syntax continues to escape me.
In this particular instance, I would like a macro that searches for two
consecutive paragraph returns and tests the *style* of the second of the
consecutive paragraph returns. If the *style* of the second paragraph return
is something other than *normal*, I would like for the Macro to change the
*style* of this second paragraph return to *normal*.
I would like for the macro to continue in this effort until such time as it
reaches the end of the document.
The following is what I have come up with so far through the use of the
Macro Recorder. The ability to fill in the remaining necessary coding and to
then get the coding to repeat until the end of the document is what is
currently causing me problems.
Sub LoopThroughDocument()
'
selection.Find.ClearFormatting
With selection.Find
.Text = "^p^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
selection.Find.Execute
selection.MoveRight Unit:=wdCharacter, Count:=1
selection.MoveLeft Unit:=wdCharacter, Count:=1
If selection.Style <> "Normal" Then
selection.Style = "Normal"
End If
Loop
End Sub
If any of you is able to come up with suggestions, I would be very
appreciative.
Thanks in advance – Rod
In an effort to begin the learning process of VBA I am attempting to create
some uncomplicated macros which hopefully apply to any document with which I
am actively involved. However, I am finding that thus far even the most
rudimentary and simplest of the VBA syntax continues to escape me.
In this particular instance, I would like a macro that searches for two
consecutive paragraph returns and tests the *style* of the second of the
consecutive paragraph returns. If the *style* of the second paragraph return
is something other than *normal*, I would like for the Macro to change the
*style* of this second paragraph return to *normal*.
I would like for the macro to continue in this effort until such time as it
reaches the end of the document.
The following is what I have come up with so far through the use of the
Macro Recorder. The ability to fill in the remaining necessary coding and to
then get the coding to repeat until the end of the document is what is
currently causing me problems.
Sub LoopThroughDocument()
'
selection.Find.ClearFormatting
With selection.Find
.Text = "^p^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
selection.Find.Execute
selection.MoveRight Unit:=wdCharacter, Count:=1
selection.MoveLeft Unit:=wdCharacter, Count:=1
If selection.Style <> "Normal" Then
selection.Style = "Normal"
End If
Loop
End Sub
If any of you is able to come up with suggestions, I would be very
appreciative.
Thanks in advance – Rod