Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Find & Replace &vba: formatting, like bold
I need a macro that searches for telephone numbers and replaces them
with same number + format = bold. How? Recording a macro for this does not work: the recorded macro only deletes the telephone numbers =). So I search for one of these: ^#^#^# ^#^#^#^# ^#^#^# ^#^#^# ^#^#^#^# ^#^#^#^ #^#^# ^#^#^#^ |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Find & Replace &vba: formatting, like bold
Are you using ^& as the "Replace with" text?
-- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. wrote in message oups.com... I need a macro that searches for telephone numbers and replaces them with same number + format = bold. How? Recording a macro for this does not work: the recorded macro only deletes the telephone numbers =). So I search for one of these: ^#^#^# ^#^#^#^# ^#^#^# ^#^#^# ^#^#^#^# ^#^#^#^ #^#^# ^#^#^#^ |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Find & Replace &vba: formatting, like bold
Unfortunately the macro recorder will not add the bold attribute. You will
have to add it to the macro Given that the posted strings are not viable search strings (well the third one isn't - I have changed it to 000 000 0000) the following macro will work: Sub ReplaceList() Dim vFindText As Variant Dim vReplText As Variant Dim i As Long vFindText = Array("^#^#^# ^#^#^#^#", _ "^#^#^# ^#^#^# ^#^#^#^#", _ "^#^#^# #^#^# ^#^#^#^#") Selection.HomeKey Unit:=wdStory With Selection.Find .Forward = True .Wrap = wdFindContinue .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Format = True .MatchCase = True For i = LBound(vFindText) To UBound(vFindText) .Text = vFindText(i) .Replacement.Text = "^&" .Replacement.Font.Bold = True .Execute replace:=wdReplaceAll Next i End With End Sub Suzanne S. Barnhill wrote: Are you using ^& as the "Replace with" text? wrote in message oups.com... I need a macro that searches for telephone numbers and replaces them with same number + format = bold. How? Recording a macro for this does not work: the recorded macro only deletes the telephone numbers =). So I search for one of these: ^#^#^# ^#^#^#^# ^#^#^# ^#^#^# ^#^#^#^# ^#^#^#^ #^#^# ^#^#^#^ |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Find & Replace &vba: formatting, like bold
Excellent, works!
How should I modify this macro so that it is not applied to whole document? I would like it to be applied to only selected text. |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Find & Replace &vba: formatting, like bold
1. Remove this line (which makes it start at the beginning of the document):
Selection.HomeKey Unit:=wdStory 2. Change this line (which amkes it loop when it's done the selection): .Wrap = wdFindContinue To this (which makes it stop when it's done the selection): .Wrap = wdFindStop -- Enjoy, Tony wrote in message oups.com... Excellent, works! How should I modify this macro so that it is not applied to whole document? I would like it to be applied to only selected text. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using find and replace or macros to replace page ranges | Microsoft Word Help | |||
Find and Replace GREEK symbols in XP, 2K & 97 | Microsoft Word Help | |||
Find (NO formatting) not finding word that IS there. | Microsoft Word Help | |||
Replace Formatting With Tags | Microsoft Word Help | |||
Find Replace bold formatting with delimiter | Microsoft Word Help |