Hi Steve,
not quite simple.
I'm assuming, that you want all characters
before the first parenthesis to be bold,
and that there is no other text,
to which the definition in the search patterns would apply.
Sub RaceBaseBold2()
Dim rDcm As Range
Dim rTmp As Range
Set rDcm = ActiveDocument.Range
ResetSearch
With rDcm.Find
.Text = "[A-Za-z]{1,}\([0-9 ]{2,}\)"
.MatchWildcards = True
While .Execute
Set rTmp = rDcm
With rTmp.Find
.Text = "[A-Za-z]{1,}"
If .Execute Then
rTmp.Font.Bold = True
End If
End With
rDcm.Collapse direction:=wdCollapseEnd
rDcm.End = ActiveDocument.Range.End
.Text = "[A-Za-z]{1,}\([0-9 ]{2,}\)"
Wend
End With
ResetSearch
End Sub
Public Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
' plus some more if needed
.Execute
End With
End Sub
Greetings from Bavaria, Germany
Helmut Weber, MVP, WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Steved - 06 Jul 2005 20:25 GMT
Hello Helmut,
Once again thankyou it is exactly as you have put it together.
Cheers.
> Hi Steve,
>
[quoted text clipped - 53 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
Steved - 07 Jul 2005 05:43 GMT
Hello Helmut from Steved
parenthesis bold to ) ie J( 2 0 0) Hr(14 2 2)
would you be so kind please to extend your macro to acheive the above
Thankyou.
> Hi Steve,
>
[quoted text clipped - 53 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
Helmut Weber - 07 Jul 2005 12:37 GMT
Hi Steve,
like this:
Sub RaceBaseBold3()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
ResetSearch
With rDcm.Find
.Text = "[A-Za-z]{1,}\([0-9 ]{2,}\)"
.MatchWildcards = True
While .Execute
With rDcm.Find
.Text = "[A-Za-z]{1,}\("
If .Execute Then
rDcm.Font.Bold = True
End If
.Text = "\)"
rDcm.Collapse direction:=wdCollapseEnd
rDcm.End = ActiveDocument.Range.End
If .Execute Then
rDcm.Font.Bold = True
End If
End With
rDcm.Collapse direction:=wdCollapseEnd
rDcm.End = ActiveDocument.Range.End
.Text = "[A-Za-z]{1,}\([0-9 ]{2,}\)"
Wend
End With
ResetSearch
End Sub
Note, that I have omitted the temporary range rTmp,
as it isn't required. One could even think of developing
a recursive procedure, for searching in the result of
a search. But that's another story.
Beware of typos ";" (German) vs. "," (International)
in the search-patterns.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Steved - 07 Jul 2005 22:01 GMT
Thanks Helmut Have a good day.
Cheers
> Hi Steve,
>
[quoted text clipped - 40 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
Steved - 07 Jul 2005 22:22 GMT
Sorry Helmut can you adjust your macro to bold between ( ) please so the end
result would be your macro bolds everything ie J( 2 0 0), Hr(14 2 2)
Thankyou.
> Thanks Helmut Have a good day.
>
[quoted text clipped - 44 lines]
> > "red.sys" & chr(64) & "t-online.de"
> > Word 2002, Windows 2000
Helmut Weber - 07 Jul 2005 22:36 GMT
Hi Steve,
like this, and in some other ways:
Sub RaceBaseBold0()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
ResetSearch
With rDcm.Find
.Text = "[A-Za-z]{1,}\([0-9 ]{2,}\)"
.MatchWildcards = True
While .Execute
rDcm.Font.Bold = True
Wend
End With
ResetSearch
End Sub
Greetings from Bavaria, Germany
Helmut Weber, MVP, WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Steved - 07 Jul 2005 22:56 GMT
Hello Helmut Excellent.
Thanks for your time.
Cheers.
> Hi Steve,
>
[quoted text clipped - 20 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"