Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 06-11-2014, 10:10 AM
NobodysPerfect NobodysPerfect is offline Wildcard search fails in table Windows 8 Wildcard search fails in table Office 2010 32bit
Competent Performer
Wildcard search fails in table
 
Join Date: Jan 2014
Location: Germany
Posts: 136
NobodysPerfect is on a distinguished road
Default

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
Data between "Pos." and "Wert" shall be highlighted - with some exceptions within the highlighted area. So part one highlights the range from "Pos." to "Wert", part two 're-paints' given strings (incl. "Pos." and "Wert").

As I wrote, works fine, but ignores tables.

Thanks
NP
Reply With Quote
 



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
Wildcard search fails in table Tricky wildcard search NobodysPerfect Word 10 03-19-2014 04:29 AM
Wildcard search fails in table Data table search function omtinole Excel Programming 1 07-13-2012 10:03 PM
Wildcard search fails in table 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft