![]() |
|
#1
|
|||
|
|||
|
Hi to all,
within a procedure I have a simple wildcard search "FirstItem*LastItem" to hightlight the passages between two given items. It works fine: except in tables. Whenever the items are within a table Search & Replace simply ignores them. So my question: does Word's wildcard seach really ignores text in tables? Or am I doing sth wrong. Thanks for your answers. NP |
|
#2
|
|||
|
|||
|
Your doing something wrong. Without seeing your code, "what" is anyone's guess.
|
|
#3
|
|||
|
|||
|
Ok, here it comes:
Code:
Sub HighlightRanges()
Dim doc As Document: Set doc = ActiveDocument
Dim SRange As Range: Set SRange = doc.Range
Dim RePaintText As Variant
Dim i As Long
RePaintText = Array("Pos.", "Wert", "077.0087")
Application.ScreenUpdating = False
ClearFindnReplace
Options.DefaultHighlightColorIndex = wdViolet
With SRange.Find
.Text = "Pos.*Wert"
.Replacement.Highlight = True
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
ClearFindnReplace
Options.DefaultHighlightColorIndex = wdYellow
With SRange.Find
.Replacement.Highlight = True
For i = LBound(RePaintText) To UBound(RePaintText)
.Text = RePaintText(i)
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub
Sub ClearFindnReplace()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
End Sub
As I wrote, works fine, but ignores tables. Thanks NP |
|
#4
|
|||
|
|||
|
Let me revise my earlier statement. Your code works if the Pos. ????? Wert is in the same cell. However, if is spans multiple cells, then yes it appears that the wildcard "*" will not work.
Sorry for misleading you. |
|
#5
|
|||
|
|||
|
Hi,
I never noticed that (bug?) before. Good to know. I will switch to a two-range-search, but that will be considerably slower .Cheers NP |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Change characters outside a wildcard while keeping wildcard results | nymusicman | Word VBA | 2 | 04-10-2014 08:17 AM |
Tricky wildcard search
|
NobodysPerfect | Word | 10 | 03-19-2014 04:29 AM |
Data table search function
|
omtinole | Excel Programming | 1 | 07-13-2012 10:03 PM |
Search always fails in Word 2007
|
Sachelis | Word | 2 | 01-28-2011 08:50 AM |
| Wildcard search help. | Kempston | Word | 0 | 11-13-2009 03:58 AM |