Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2014, 08:24 PM
Sandhya Sandhya is offline Search the words of different document Windows 7 32bit Search the words of different document Office 2007
Novice
Search the words of different document
 
Join Date: Nov 2014
Posts: 21
Sandhya is on a distinguished road
Default Search the words of different document

I have active document, which is opened, need search for the symbols and special words from the different document whether those will available in this they should be highlighted.
Reply With Quote
  #2  
Old 11-22-2014, 08:27 PM
Sandhya Sandhya is offline Search the words of different document Windows 7 32bit Search the words of different document Office 2007
Novice
Search the words of different document
 
Join Date: Nov 2014
Posts: 21
Sandhya is on a distinguished road
Default Document search and highlight

Search for the strings i.e. one are two spaces words and symbols which are existing in different document. if they found in active document they should highlight.

Please do the needful.
Reply With Quote
  #3  
Old 11-22-2014, 08:30 PM
Sandhya Sandhya is offline Search the words of different document Windows 7 32bit Search the words of different document Office 2007
Novice
Search the words of different document
 
Join Date: Nov 2014
Posts: 21
Sandhya is on a distinguished road
Default

Please help me.
Reply With Quote
  #4  
Old 11-22-2014, 09:08 PM
macropod's Avatar
macropod macropod is offline Search the words of different document Windows 7 64bit Search the words of different document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Such impatience (3 posts on the same topic in 6 minutes) does nothing to endear you to anyone who might be inclined to help.

As it is, a Search of these forums will return a number of threads in which the use of search terms in a document, text file or Excel worksheet can be used for running a Find/Replace operation on one or more documents.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 11-22-2014, 09:21 PM
Sandhya Sandhya is offline Search the words of different document Windows 7 32bit Search the words of different document Office 2007
Novice
Search the words of different document
 
Join Date: Nov 2014
Posts: 21
Sandhya is on a distinguished road
Default Macro to search for phrases in the word document

Dear All,

Please hep me in this regard

I would like to search and highlist the phrases ex: "can not", "has to", "have to" and "such as"
Reply With Quote
  #6  
Old 11-22-2014, 11:13 PM
gmayor's Avatar
gmayor gmayor is offline Search the words of different document Windows 7 64bit Search the words of different document Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Create a document with a single column table. Put one of the phrases in each cell (no blanks) save the document then put the name and path in the following macro in place of "C:\Path\Table.docx". Run the macro on your document with the phrases.

Code:
Sub Highlighting()
Dim oChanges As Document, oDoc As Document
Dim oTable As Table
Dim oCell As Cell
Dim oRng As Range
Dim rFindText As Range
Const sFname As String = "C:\Path\Table.docx"
    Set oDoc = ActiveDocument
    Set oChanges = Documents.Open(Filename:=sFname, Visible:=False)
    Set oTable = oChanges.Tables(1)
    For Each oCell In oTable.Range.Cells
        If Len(oCell.Range) > 2 Then
            Set oRng = oDoc.Range
            Set rFindText = oCell.Range
            rFindText.End = rFindText.End - 1
            With oRng.Find
                .ClearFormatting
                .Replacement.ClearFormatting
                Do While .Execute(FindText:=rFindText, _
                                  MatchWholeWord:=True) = True
                    oRng.HighlightColorIndex = wdBrightGreen
                Loop
            End With
        End If
    Next oCell
lbl_Exit:
    oChanges.Close 0
    Set oChanges = Nothing
    Set oDoc = Nothing
    Set oRng = Nothing
    Set rFindText = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #7  
Old 11-23-2014, 01:59 AM
macropod's Avatar
macropod macropod is offline Search the words of different document Windows 7 64bit Search the words of different document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Sandhya: This is the fourth post you've made today on essentially the same topic. Did you even bother to look at any of the numerous threads that have already discussed and resolved such issues, as suggested in post #4, above?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 11-23-2014, 02:51 AM
Sandhya Sandhya is offline Search the words of different document Windows 7 32bit Search the words of different document Office 2007
Novice
Search the words of different document
 
Join Date: Nov 2014
Posts: 21
Sandhya is on a distinguished road
Default search and highlight the symbols and special characters

Dear Sll,

please help me search for special characters like cd/in2, Ci, dm2, dm2, ft 2/s and so on.

please help me for write macro.
Reply With Quote
  #9  
Old 11-23-2014, 02:54 AM
Sandhya Sandhya is offline Search the words of different document Windows 7 32bit Search the words of different document Office 2007
Novice
Search the words of different document
 
Join Date: Nov 2014
Posts: 21
Sandhya is on a distinguished road
Default

Thank you so much for your help, can and add the symbols and special charaters also in the tabble??

please help me.
Reply With Quote
  #10  
Old 11-23-2014, 03:01 AM
gmayor's Avatar
gmayor gmayor is offline Search the words of different document Windows 7 64bit Search the words of different document Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Whatever you enter in the table will be added to the search list.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #11  
Old 11-23-2014, 03:02 AM
gmayor's Avatar
gmayor gmayor is offline Search the words of different document Windows 7 64bit Search the words of different document Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

See your other thread - https://www.msofficeforums.com/word-...-document.html
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #12  
Old 11-23-2014, 02:42 PM
macropod's Avatar
macropod macropod is offline Search the words of different document Windows 7 64bit Search the words of different document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Sandhya: Kindly don't keep starting new threads on the same topic. So far, this is the fourth thread you've started on this topic and it looks very much like you simply expect people to do everything for you - immediately. This is not a free coding forum for impatient people who are too lazy to either search for solutions to similar problems or to learn from the solutions they have already been given...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 11-24-2014, 08:41 AM
Sandhya Sandhya is offline Search the words of different document Windows 7 32bit Search the words of different document Office 2007
Novice
Search the words of different document
 
Join Date: Nov 2014
Posts: 21
Sandhya is on a distinguished road
Default Seach for the whole word

Dear All,

As below code i am able to search for the words existing in the table, but it is not checking as a whole in active document.

example: if i keep the abbrevations like "ar" means "as required" and "in" means inch, where as it is highlight all ar letters where ever it is finding,

from the word argument it is highlighting ar and in from instructions first two letters,

Kindly help me in this regard.


Quote:
Originally Posted by gmayor View Post
Create a document with a single column table. Put one of the phrases in each cell (no blanks) save the document then put the name and path in the following macro in place of "C:\Path\Table.docx". Run the macro on your document with the phrases.

Code:
Sub Highlighting()
Dim oChanges As Document, oDoc As Document
Dim oTable As Table
Dim oCell As Cell
Dim oRng As Range
Dim rFindText As Range
Const sFname As String = "C:\Path\Table.docx"
    Set oDoc = ActiveDocument
    Set oChanges = Documents.Open(Filename:=sFname, Visible:=False)
    Set oTable = oChanges.Tables(1)
    For Each oCell In oTable.Range.Cells
        If Len(oCell.Range) > 2 Then
            Set oRng = oDoc.Range
            Set rFindText = oCell.Range
            rFindText.End = rFindText.End - 1
            With oRng.Find
                .ClearFormatting
                .Replacement.ClearFormatting
                Do While .Execute(FindText:=rFindText, _
                                  MatchWholeWord:=True) = True
                    oRng.HighlightColorIndex = wdBrightGreen
                Loop
            End With
        End If
    Next oCell
lbl_Exit:
    oChanges.Close 0
    Set oChanges = Nothing
    Set oDoc = Nothing
    Set oRng = Nothing
    Set rFindText = Nothing
    Exit Sub
End Sub
Reply With Quote
  #14  
Old 11-24-2014, 08:54 AM
Sandhya Sandhya is offline Search the words of different document Windows 7 32bit Search the words of different document Office 2007
Novice
Search the words of different document
 
Join Date: Nov 2014
Posts: 21
Sandhya is on a distinguished road
Default search for whole word means should check for before and after space

Dear All,

As below code i am able to search for the words existing in the table, but it is not checking as a whole in active document.

example: if i keep the abbrevations like "ar" means "as required" and "in" means inch, where as it is highlight all ar letters where ever it is finding,

from the word argument it is highlighting ar and in from instructions first two letters,

Kindly help me in this regard.


Quote:
Originally Posted by gmayor View Post
Create a document with a single column table. Put one of the phrases in each cell (no blanks) save the document then put the name and path in the following macro in place of "C:\Path\Table.docx". Run the macro on your document with the phrases.

Code:
Sub Highlighting()
Dim oChanges As Document, oDoc As Document
Dim oTable As Table
Dim oCell As Cell
Dim oRng As Range
Dim rFindText As Range
Const sFname As String = "C:\Path\Table.docx"
Set oDoc = ActiveDocument
Set oChanges = Documents.Open(Filename:=sFname, Visible:=False)
Set oTable = oChanges.Tables(1)
For Each oCell In oTable.Range.Cells
If Len(oCell.Range) > 2 Then
Set oRng = oDoc.Range
Set rFindText = oCell.Range
rFindText.End = rFindText.End - 1
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(FindText:=rFindText, _
MatchWholeWord:=True) = True
oRng.HighlightColorIndex = wdBrightGreen
Loop
End With
End If
Next oCell
lbl_Exit:
oChanges.Close 0
Set oChanges = Nothing
Set oDoc = Nothing
Set oRng = Nothing
Set rFindText = Nothing
Exit Sub
End Sub
Reply With Quote
  #15  
Old 11-24-2014, 01:27 PM
macropod's Avatar
macropod macropod is offline Search the words of different document Windows 7 64bit Search the words of different document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Well, of course it does. There is no way Word can tell whether 'ar' or 'in' is an abbreviation. You would reduce the risk of false matches if your abbreviations followed the convention of incorporating periods in them (e.g. 'a.r.' or 'in.') and included the period(s) as part of the Find text, but even that won't stop 'in.' for example being matched here:
I found a bin to put it in.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Search the words of different document Search for italicized words ep2002 Word 4 11-10-2014 10:23 PM
Macro to Search for all words with (R) and place in new document kd12 Word VBA 2 06-10-2014 02:25 PM
How to search for 2 words at the same time mrayncrental Word VBA 1 06-08-2014 03:08 AM
Multiple words, one search return2300 Word VBA 0 08-30-2013 12:26 PM
Search the words of different document Search for words starting in capitals surreytom Word VBA 3 04-01-2012 01:41 AM

Other Forums: Access Forums

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