Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-11-2014, 08:55 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 Wildcard search fails in table

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
Reply With Quote
  #2  
Old 06-11-2014, 09:47 AM
gmaxey gmaxey is offline Wildcard search fails in table Windows 7 32bit Wildcard search fails in table Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Your doing something wrong. Without seeing your code, "what" is anyone's guess.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #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
  #4  
Old 06-11-2014, 10:54 AM
gmaxey gmaxey is offline Wildcard search fails in table Windows 7 32bit Wildcard search fails in table Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 06-11-2014, 11:02 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

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
Reply With Quote
Reply



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 01:48 AM.


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