Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2016, 01:59 PM
Cosmo Cosmo is offline Having problems with a Wildcard search Windows Vista Having problems with a Wildcard search Office 2007
Competent Performer
Having problems with a Wildcard search
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default


Here's the final code I am using:

Code:
    Dim oDoc As Document    
    Dim rng As Word.Range
    Dim rngISIDrugName As Word.Range
    Dim pgNumber As Integer
    Dim currentPageNumber As Integer
    
    Set oDoc = ActiveDocument
    Set rng = oDoc.Range
    
    With rng
        With .Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .MatchWildcards = True
            .Replacement.Text = "BRAND\1"
            .Forward = True
            .Text = "BRAND®([!\(]{1,5})\([!\)]@\)"
            .Execute
        End With
        While .Find.Found = True
            pgNumber = .Information(Word.WdInformation.wdActiveEndAdjustedPageNumber)
            If pgNumber = currentPageNumber Then
                .Find.Execute Replace:=wdReplaceOne
                ' NOTE - Need to remove extra space here!
                If (Right(.Text, 1) = " ") Then
                    .Text = Left(.Text, Len(.Text) - 1)
                End If
                .Collapse wdCollapseEnd
            Else
                currentPageNumber = pgNumber
            End If
            .Find.Execute
        Wend
    End With
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with wildcard search mysterytramp Word 0 05-13-2015 10:40 AM
Where is the error in my wildcard search? Ulodesk Word 10 06-30-2014 01:46 PM
Having problems with a Wildcard search Wildcard search fails in table NobodysPerfect Word VBA 4 06-11-2014 11:02 AM
Having problems with a Wildcard search Tricky wildcard search NobodysPerfect Word 10 03-19-2014 04:29 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 04:09 AM.


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