Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 05-02-2017, 02:26 AM
raghugada raghugada is offline Find & Replace Unique word Windows XP Find & Replace Unique word Office 2007
Novice
Find & Replace Unique word
 
Join Date: Apr 2017
Posts: 21
raghugada is on a distinguished road
Default Find & Replace Unique word

Hi,



I am trying to find and replace unique alphanumeric word containing special characters
But couldn't able to find the unique word with this combination ?
  #2  
Old 05-02-2017, 03:04 AM
gmaxey gmaxey is offline Find & Replace Unique word Windows 7 32bit Find & Replace Unique word Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,441
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

So what unique word are you trying to find?
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
  #3  
Old 05-02-2017, 03:53 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: 21,962
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 am trying to find and replace unique alphanumeric word containing special characters
But couldn't able to find the unique word with this combination ?
If it's in any document or other content you have access to, you can copy it from there and paste it into the Find dialogue. If it's not found, that's most likely because it isn't in the document you're working with.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #4  
Old 05-03-2017, 04:49 AM
raghugada raghugada is offline Find & Replace Unique word Windows XP Find & Replace Unique word Office 2007
Novice
Find & Replace Unique word
 
Join Date: Apr 2017
Posts: 21
raghugada is on a distinguished road
Default

Hello

I have attached the word file attachment with font file.

I am trying to search for a word ^mb in the given document
but its searching for this word also g§^mbZm
I am looking for exact match.

So Please give me a solution for this.

Is there a way to identify the beginning of paragraph in find replace ?

This is the macro code i have pasted below

With Selection.Find
.Text = ^mb
.Replacement.Text = test
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Attached Files
File Type: zip Test Document with font.zip (55.2 KB, 11 views)
  #5  
Old 05-03-2017, 06:04 AM
gmaxey gmaxey is offline Find & Replace Unique word Windows 7 32bit Find & Replace Unique word Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,441
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 code doesn't compile so I don't see how it is finding or not finding anything.

Find whole word is disabled when certain characters are included in the find string. You could do this in steps (just make sure your document is not a thesis on the behavior of the Aardvark):

Code:
Sub InSteps()
Dim oRng As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "^^"
    .Replacement.Text = "Aardvark"
    .Execute Replace:=wdReplaceAll
    Set oRng = ActiveDocument.Range
    .Text = "Aardvarkmb"
    .Replacement.Text = "Test"
    .MatchWholeWord = True
    .Execute Replace:=wdReplaceAll
    Set oRng = ActiveDocument.Range
    .Text = "Aardvark"
    .Replacement.Text = "^^"
    .MatchWholeWord = False
    .Execute Replace:=wdReplaceAll
  End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
  #6  
Old 05-05-2017, 02:50 AM
raghugada raghugada is offline Find & Replace Unique word Windows XP Find & Replace Unique word Office 2007
Novice
Find & Replace Unique word
 
Join Date: Apr 2017
Posts: 21
raghugada is on a distinguished road
Default

Hi
I am trying to search for this word Ë_do
in the document but even then its showing selection for this word
AmË_doÎmm
It should find exact word not the subset of it
  #7  
Old 05-06-2017, 06:29 AM
gmaxey gmaxey is offline Find & Replace Unique word Windows 7 32bit Find & Replace Unique word Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,441
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

As I have already taken pains to express, the find whole word option is disregarded when using symbols and such in the find string. You have to do it in steps:

Code:
Sub InSteps()
Dim oRng As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "Ë_do"
    .Replacement.Text = "Aardvark"
    .Execute Replace:=wdReplaceAll
    Set oRng = ActiveDocument.Range
    .Text = "Aardvark"
    .Replacement.Text = "Whatever you want to replace with"
    .MatchWholeWord = True
    .Execute Replace:=wdReplaceAll
    Set oRng = ActiveDocument.Range
    .Text = "Aardvark"
    .Replacement.Text = "Ë_do"
    .MatchWholeWord = False
    .Execute Replace:=wdReplaceAll
  End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
  #8  
Old 05-07-2017, 09:37 AM
raghugada raghugada is offline Find & Replace Unique word Windows XP Find & Replace Unique word Office 2007
Novice
Find & Replace Unique word
 
Join Date: Apr 2017
Posts: 21
raghugada is on a distinguished road
Default List of symbols where it will break ?

Hi,
Can you list me out what are the symbols it will cause problem ?
  #9  
Old 05-12-2017, 03:13 AM
raghugada raghugada is offline Find & Replace Unique word Windows XP Find & Replace Unique word Office 2007
Novice
Find & Replace Unique word
 
Join Date: Apr 2017
Posts: 21
raghugada is on a distinguished road
Default track changes

Hello,

I have a list of words in excel sheet i want to find and replace in words file.
With the above code its working fine.
I want to track changes but with the above code couldn't track changes
  #10  
Old 05-12-2017, 11:21 AM
dwirony dwirony is offline Find & Replace Unique word Windows 7 64bit Find & Replace Unique word Office 2003
Advanced Beginner
 
Join Date: Oct 2016
Posts: 49
dwirony will become famous soon enough
Default Track changes

So you want to add lock protection + track changes to the code? Add this:

Code:
ActiveDocument.Protect Password:="password", NoReset:=False, Type:= _
wdAllowOnlyRevisions, UseIRM:=False, EnforceStyleLock:=True
Full macro:

Code:
Sub TrackChanges()
 
'replace password with whatever you want
 
    ActiveDocument.Protect Password:="password", NoReset:=False, Type:= _
        wdAllowOnlyRevisions, UseIRM:=False, EnforceStyleLock:=True
End Sub
  #11  
Old 05-12-2017, 07:14 PM
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: 21,962
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 dwirony View Post
So you want to add lock protection + track changes to the code?
Protection really has nothing to do with raghugada's 'Track Changes' issue. The issue concerns the Find/Replace apparently not working with 'Track Changes'. The most likely cause is that what is to be found by the Find expression spans a range that partly includes a 'Tracked Change'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #12  
Old 05-12-2017, 07:17 PM
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: 21,962
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 track changes but with the above code couldn't track changes
Well, there's nothing in the code that relates to 'Track Changes', so whether any changes as a result of the Find/Replace are tracked depends entirely on whether you have 'Track Changes' on. If, however, your concern is that the Find is not matching with some strings, the most likely cause is that what is to be found by the Find expression spans a range that partly includes a 'Tracked Change'. You need to provide more details.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #13  
Old 05-13-2017, 10:36 PM
raghugada raghugada is offline Find & Replace Unique word Windows XP Find & Replace Unique word Office 2007
Novice
Find & Replace Unique word
 
Join Date: Apr 2017
Posts: 21
raghugada is on a distinguished road
Default track changes

This is the code i am working on
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
Code:
Sub RemoveShreeLipiDistortion()
    Dim username As String
    username = Application.username
    Application.username = "RemoveShreeLipiDistortion"
    Dim showrevisionsflag As Boolean
    showrevisionsflag = ActiveWindow.View.ShowRevisionsAndComments
    With ActiveWindow.View
        .ShowRevisionsAndComments = False
        .RevisionsView = wdRevisionsViewFinal
        .Reviewers.Item("RemoveShreeLipiDistortion").Visible = True
    End With
    
    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
        ActiveDocument.TrackRevisions = False
        With oRng.Find
            .Text = Replace(exWb.Worksheets(1).Range("A" & i), "^", "^^")
            .Replacement.Text = "Aardvark"
            .MatchCase = True
            .MatchWholeWord = True
            .Execute Replace:=wdReplaceAll
        End With
        ActiveDocument.TrackRevisions = True
        Set oRng = ActiveDocument.Range
        With oRng.Find
            .Text = "Aardvark"
            .Replacement.Text = Replace(exWb.Worksheets(1).Range("B" & i), "^", "^^")
            .MatchCase = True
            .MatchWholeWord = True
            .Execute Replace:=wdReplaceAll
        End With
        ActiveDocument.TrackRevisions = False
        Set oRng = ActiveDocument.Range
        With oRng.Find
            .Text = "Aardvark"
            .Replacement.Text = Replace(exWb.Worksheets(1).Range("A" & i), "^", "^^")
            .MatchCase = True
            .MatchWholeWord = False
            .Execute Replace:=wdReplaceAll
        End With
        ActiveDocument.TrackRevisions = True
    Next i
    exWb.Close
    Set exWb = Nothing
    Set objExcel = Nothing
    ActiveWindow.View.ShowRevisionsAndComments = showrevisionsflag
    Application.username = username
End Sub

Last edited by macropod; 05-14-2017 at 04:28 AM. Reason: Added code tags
  #14  
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: 21,962
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]
  #15  
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 >
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 08:17 PM.


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