Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2011, 05:35 AM
Guy Roth Guy Roth is offline search on multiple word documents Windows 7 32bit search on multiple word documents Office 2010 32bit
Novice
search on multiple word documents
 
Join Date: Nov 2011
Posts: 20
Guy Roth is on a distinguished road
Default search on multiple word documents

Is there any tool of office or addon to it that allow me to search for a text that can be in one of several word documents that are related to each other and located in the same folder?

I actullay split one big document to several ones (it's easy to maintain them this way) but I'd like to be able to search and find in all of them at once.


Reply With Quote
  #2  
Old 11-13-2011, 05:56 AM
macropod's Avatar
macropod macropod is online now search on multiple word documents Windows 7 64bit search on multiple word documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,466
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi Guy,

You could do that with a macro like:
Code:
Sub MultiDocumentSearch()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc as Document, strFind as String
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
strFind = InputBox("String to Find?")
If strFind = "" Then Exit Sub
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdDoc.Range.Find
    .ClearFormatting
    .Text = strFind
    .Replacement.Text = "^&"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = True
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
  End With
  wdDoc.Close SaveChanges:=True
  strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
The macro prompts you for a folder to look in and the string to find, then searches for that string in all documents in the nominated folder. You'd need to add a bit more code to make it do something useful with whatever's found, though.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-13-2011, 06:01 AM
Guy Roth Guy Roth is offline search on multiple word documents Windows 7 32bit search on multiple word documents Office 2010 32bit
Novice
search on multiple word documents
 
Join Date: Nov 2011
Posts: 20
Guy Roth is on a distinguished road
Default

Thanks - but I am not experienced with Macros and don't want to start maintaining one.

So I am still looking for some tool that already have a proven implementation of such functionality
Reply With Quote
  #4  
Old 11-13-2011, 10:59 PM
macropod's Avatar
macropod macropod is online now search on multiple word documents Windows 7 64bit search on multiple word documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,466
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi Guy,

There may be some commercial applications, but they'll be less customizable to your needs than a macro such as the one I posted. Furthermore, a commercial application will quite possibly be nothing more than a macro distributed as an add-in. In any event, the macro I posted should require no maintenance on your part - all that needs to be maintained in the file containing the Find/Replace list (something almost anyone could do).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 03-04-2017, 06:39 PM
gstech gstech is offline search on multiple word documents Windows 7 search on multiple word documents Office 2007
Novice
 
Join Date: Oct 2010
Posts: 6
gstech is on a distinguished road
Default

What does this macro actually do? I installed the macro in a .docm file and ran the code. I selected a folder and search string. There were no messages but I don't know where to get the results.
Reply With Quote
  #6  
Old 03-05-2017, 02:05 PM
macropod's Avatar
macropod macropod is online now search on multiple word documents Windows 7 64bit search on multiple word documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,466
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

It does what the OP asked for - find & replace a nominated string in all documents in a folder. The results will be in the updated files.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 03-06-2017, 08:28 AM
gstech gstech is offline search on multiple word documents Windows 7 search on multiple word documents Office 2007
Novice
 
Join Date: Oct 2010
Posts: 6
gstech is on a distinguished road
Default

I asked because I could not see results, and thought I’m not understanding how it works.
Your macro code includes: .Replacement.Text = "^&"

question1: Is “^&” a code? When I changed this to .Replacement.Text = “XX” I could see my target files were changed. But I couldn’t see changes with “^&”.

question2. What is the “Find/Replace” list that you mentioned?

question3: I understood the OP was asking for “find”, not “find/replace”. That’s what I was looking for also. There are several ways to report finds to the user. One is to stop at the first occurrence and display the document (the page, with the found word highlighted). This is helpful when the user wants to read the page, but does not want to replace anything. Has that option been discussed here?

Thanks for your help.
Reply With Quote
  #8  
Old 03-06-2017, 01:31 PM
macropod's Avatar
macropod macropod is online now search on multiple word documents Windows 7 64bit search on multiple word documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,466
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

1. The ^& is a standard Find/Replace replacement expression. The fact it's used in a macro makes no difference. All it does is replace what's found with itself. As I said in my reply to the OP:
Quote:
You'd need to add a bit more code to make it do something useful with whatever's found
As the code stands, all that's liable to happen in this case is that the files containing the text would have their date/time stamps updated.

2. The 'Find/Replace list' referred to in post #4 could be an array or pair of arrays built into the code itself, a series of tab-delimited paragraphs in a document or plain text file, a two-column Word table, two columns in an Excel workbook, etc., etc. Different code is required for each kind of list. For code that uses an Excel workbook for the list, see:
https://www.msofficeforums.com/word-...html#post34254

3. Quite clearly, the option to do anything of substance has not been discussed in this thread. The code provided is little more than a skeleton. If you want something that provides a measure of interactivity, see:
https://www.msofficeforums.com/word-...html#post31849
If your needs are different, I suggest you start a new thread setting out exactly what you're trying to achieve.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
search, search folders

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
search on multiple word documents Replace text in multiple documents? Roscoe Word VBA 8 07-31-2017 04:02 PM
Word 2010 / Master Index / Multiple Documents bawrites Word 0 08-09-2011 11:02 AM
search on multiple word documents Change Multiple Documents from US to UK language swifty2010 Word 1 03-08-2011 02:00 PM
2007 merging multiple documents into one master hugheso Word 0 04-02-2009 04:31 AM
search on multiple word documents page numbering across multiple documents reitdesign Word 3 12-12-2008 11:55 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 03:31 PM.


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