Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-13-2011, 05:56 AM
macropod's Avatar
macropod macropod is offline 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: 22,520
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

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
 

Tags
search, search folders



Similar Threads
Thread Thread Starter Forum Replies Last Post
search on multiple word documents Replace text in multiple documents? Roscoe Word VBA 7 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

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