Need a little help please to extend my find - not sure what is best way - the original pattern does not find "hard space" but word "Section" may have 1 soft or 1 hard space after word "Section". The word "Section" will always have a capital letter.
to include "Section^s10" without followed by "number.number" or
1 soft space after word "Section "
[As a side note the word section should look like: "Section^s" not "Section ". So it is possible to just find/replace that on its own or to include both options in the find which means I am moving to an array?
This is the group I need to find (with either a soft space or ^s space after word "Section" it then "bolds" the selection:
"Section 2.3(b)(i)"
"Section 5"
"Section 12.12(a)
"Section 10.1"
include "Section^s10" without followed by "number.number" or
1 soft space after word "Section "
This is what works now for above search:
'after each successful find of the text, start expanding what was
'found and see if it contains parenthetical characters.
'Section [0-9]{1,}.[0-9]{1,}
Sub SectionBoldWords()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Section^s[0-9]{1,}.[0-9]{1,}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, _
Count:=1, Extend:=wdExtend
While Right(Selection.Text, 1) = "("
Selection.MoveRight Unit:=wdCharacter, _
Count:=1, Extend:=wdExtend
While Right(Selection.Text, 1) <> ")"
Selection.MoveRight Unit:=wdCharacter, _
Count:=1, Extend:=wdExtend
Wend
Selection.MoveRight Unit:=wdCharacter, _
Count:=1, Extend:=wdExtend
Wend
Selection.MoveRight Unit:=wdCharacter, _
Count:=-1, Extend:=wdExtend
Selection.Font.Bold = True
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Find.Execute
Wend
End Sub
Russ - 30 Aug 2007 18:27 GMT
This would be one way I would try:
Using the .find.text below:
ActiveDocument.Content.InsertBefore vbCr
Do this before search, in case a 'Section' is on first paragraph.
Then after search:
ActiveDocument.Characters(1).Delete
If by itself, on one paragraph.
With....
.Font.Bold = True
.Text = "^13(Section[ ^s][0-9]*)^13" 'looking for soft or hard space
.Replacement.Text = "\1"
.Execute Replace:=wdReplaceAll
End With
Or instead of bolding, change the style to a heading style, then you look at
document in Outline View.
.Style = wdStyleHeading1
But where are you getting these manually formatted headings or listings?
Word can create and update listings automatically.
> Need a little help please to extend my find - not sure what is best way - the
> original pattern does not find "hard space" but word "Section" may have 1 soft
[quoted text clipped - 58 lines]
> Wend
> End Sub

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Summer - 31 Aug 2007 01:14 GMT
It is only search for "Section 10" or "Section 10.1" or "Section 10.1(a)" or
"Sections 10.1 and 10.2"
It is just words in paragraphs nothing to do with autostyles. The search I
have works great it just doesn't search all the appropriate "finds" as
above.
> This would be one way I would try:
>
[quoted text clipped - 87 lines]
>> Wend
>> End Sub
Russ - 31 Aug 2007 10:34 GMT
Summer,
Further testing shows this works pretty well
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "Section[s ^s]@[0-9.\(\)a-z ]{1,}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
'.AllDocuments = True 'Uncomment to do all open docs
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
> It is only search for "Section 10" or "Section 10.1" or "Section 10.1(a)" or
> "Sections 10.1 and 10.2"
[quoted text clipped - 93 lines]
>>> Wend
>>> End Sub

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Russ - 31 Aug 2007 10:57 GMT
Oops, I pasted the wrong one before. Try this one.
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "Section[s ^s]@[0-9.\(\)a-z ]{1,}"
.Replacement.Text = "^&"
.Replacement.Font.Bold = True
.Forward = True
.Wrap = wdFindContinue
'.AllDocuments = True
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
> Summer,
>
[quoted text clipped - 113 lines]
>>>> Wend
>>>> End Sub

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Summer - 31 Aug 2007 13:53 GMT
Almost got them all - thank for the help...
> Oops, I pasted the wrong one before. Try this one.
>
[quoted text clipped - 141 lines]
>>>>> Wend
>>>>> End Sub