Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2005

Tip: Looking for answers? Try searching our database.

Reconize 2 characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steved - 06 Jul 2005 07:54 GMT
Hello from Steved

J( 2 0 0) the macro is ok to bold

Hr(14 2 2) what do I add to the macro please to catch the Hr to bold

Sub RaceBaseBold()
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
       .Text = "[A-Z]\([0-9 ]{2,}\)"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       .Format = True
       .MatchCase = False
       .MatchWholeWord = False
       .MatchAllWordForms = False
       .MatchSoundsLike = False
       .MatchWildcards = True
       .Replacement.Text = ""
       .Replacement.Font.Size = "8"
       .Replacement.Font.Bold = True
   Selection.Find.Execute Replace:=wdReplaceAll
   End With
End Sub
Thankyou.
Helmut Weber - 06 Jul 2005 15:40 GMT
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"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.