Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 05-14-2017, 04:50 AM
macropod's Avatar
macropod macropod is offline Find & Replace Unique word Windows 7 64bit Find & Replace Unique word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by raghugada View Post
I want to maintain the track changes only for the exact word match.
Need to know the original word in track change so that we can track of which word is replace by which one
In that case, since you're using symbols and '.MatchWholeWord = True', you'd do better to drop that and replace it with .MatchWildcards = True'. Then, to get whole words with case-matching, prefix the Find expression with a < chevron and suffix it with a > chevron. You could use 'Track Changes' for just that F/R expression and not for the same expression without the boundary chevrons. Beyond that, your automation code looks peculiar, to say the least. To see how to automate Find/Replace using an Excel data source, check out:
https://www.msofficeforums.com/word-...html#post34254
and:
https://www.msofficeforums.com/word-...html#post61795
and, for a demonstration of how even the Find/Replace formatting can be specified:


https://www.msofficeforums.com/word-...html#post93796
The first two process multiple documents, though the folder-processing code could be omitted and the document reference changed to just the active document, as per the code in the third link.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #2  
Old 05-15-2017, 10:10 PM
raghugada raghugada is offline Find &amp; Replace Unique word Windows XP Find &amp; Replace Unique word Office 2007
Novice
Find &amp; Replace Unique word
 
Join Date: Apr 2017
Posts: 21
raghugada is on a distinguished road
Default wild cards

I have tried using wild cards but its throwing lots of errors because of special characters

such as word ending with >
  #3  
Old 05-17-2017, 01:43 AM
raghugada raghugada is offline Find &amp; Replace Unique word Windows XP Find &amp; Replace Unique word Office 2007
Novice
Find &amp; Replace Unique word
 
Join Date: Apr 2017
Posts: 21
raghugada is on a distinguished road
Default wildcards throwing error

Distortion using wildcard.zip

I have tried using wildcards but getting error i have attached the error snap shot
I have attached the macro, word file and excel file

Code:
Sub RemoveShreeLipiDistortionUsingWildCards()
    
    Dim objExcel As Object
    Set objExcel = CreateObject("Excel.Application")

    Set exWb = objExcel.Workbooks.Open(ActiveDocument.path + "\List of ShreeLipi Distortion (1).xlsx")
    Dim counter As Integer
    counter = 1000 'exWb.Worksheets(1).Rows.Count
    Dim i As Integer
    Dim oRng As Range
    
    'For i = 250 To counter
    For i = 2 To counter
        If exWb.Worksheets(1).Range("A" & i) = "" Then
            Exit For
        End If
        Set oRng = ActiveDocument.Range
        With oRng.Find
            .Text = "<" + Replace(exWb.Worksheets(1).Range("A" & i), "^", "^^") + ">"
            .Replacement.Text = Replace(exWb.Worksheets(1).Range("B" & i), "^", "^^")
            .MatchCase = True
            '.MatchWholeWord = True
            .MatchWildcards = True
            .MatchCase = True
            .Execute Replace:=wdReplaceAll
        End With
    Next i
    exWb.Close
    Set exWb = Nothing
    Set objExcel = Nothing
End Sub

Last edited by macropod; 05-17-2017 at 10:38 PM. Reason: Added code tags
Closed Thread



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find &amp; Replace Unique word MS Word 2016 Find and Replace BillM Word 2 03-14-2017 10:49 AM
Find &amp; Replace Unique word Need help using Find & Replace (MS Word) BZee Word 9 02-16-2015 05:45 PM
Replace each heading with a unique numeric value amitkapoor Word 7 05-06-2013 03:29 AM
Find &amp; Replace Unique word Word Find and Replace Query bthart Word 1 12-29-2011 12:45 AM
Find &amp; Replace Unique word Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:15 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