I'm trying to set up a search for keywords in a specific set of files. I
don't want to have to go through and check the multitude of boxes over and
over again.
Ideally a macro button to execute such a search would be a Godsend.
Anybody have any ideas?

Thanx.

Re: Macro to Search for Keyword in Files by Helmut

Helmut
Mon Jan 07 08:24:21 PST 2008

Hi Iggitha,

what Word-version?

>I'm trying to set up a search for keywords

What keywords? Where do they come from?
Is there a list of the keywords somewhere?

>in a specific set of files.
What is the specification?

Finally, store the results (yes, no) of the search? Where?

It ain't that easy.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

RE: Macro to Search for Keyword in Files by david

david
Mon Jan 07 08:39:00 PST 2008

Iggitha:

I don't know the list rules -- am I allowed to talk about add-on tools? But
if I can, I'd like to suggest Jack Lyon's tools:

http://www.editorium.com/

I think MegaReplacer would help you lots and is probably less expensive than
developing the equivalent code yourself.

Bear
--
Windows XP, Word 2000


"Iggitha" wrote:

> I'm trying to set up a search for keywords in a specific set of files. I
> don't want to have to go through and check the multitude of boxes over and
> over again.
> Ideally a macro button to execute such a search would be a Godsend.
> Anybody have any ideas?
>
> Thanx.

Re: Macro to Search for Keyword in Files by Iggitha

Iggitha
Mon Jan 07 09:17:01 PST 2008

Gruss Gott Helmut-Thanks for your response...here are my answers to your
questions.

The version I'm using is Word 2003, and we're running Windows XP.

The Keywords would change depending on the subject matter that we are
looking for within the set of folders. These folders would always be the
same-they are final copies of letters archived by year. Each year we add a
new file.

The location of files is on a shared network drive.

If the results of the search were to be stored, it would be best if it were
on the local machine (c:\ drive).

I hope that clarifies things.
Danke,
Iggitha

"Helmut Weber" wrote:

> Hi Iggitha,
>
> what Word-version?
>
> >I'm trying to set up a search for keywords
>
> What keywords? Where do they come from?
> Is there a list of the keywords somewhere?
>
> >in a specific set of files.
> What is the specification?
>
> Finally, store the results (yes, no) of the search? Where?
>
> It ain't that easy.
>
> --
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Vista Small Business, Office XP
>

RE: Macro to Search for Keyword in Files by Iggitha

Iggitha
Mon Jan 07 09:18:01 PST 2008

Thanks Bear. I'll check it out. Not sure about rules...I'm a newbie...
Hope I didn't break any!

"Bear" wrote:

> Iggitha:
>
> I don't know the list rules -- am I allowed to talk about add-on tools? But
> if I can, I'd like to suggest Jack Lyon's tools:
>
> http://www.editorium.com/
>
> I think MegaReplacer would help you lots and is probably less expensive than
> developing the equivalent code yourself.
>
> Bear
> --
> Windows XP, Word 2000
>
>
> "Iggitha" wrote:
>
> > I'm trying to set up a search for keywords in a specific set of files. I
> > don't want to have to go through and check the multitude of boxes over and
> > over again.
> > Ideally a macro button to execute such a search would be a Godsend.
> > Anybody have any ideas?
> >
> > Thanx.

Re: Macro to Search for Keyword in Files by Helmut

Helmut
Mon Jan 07 10:47:43 PST 2008

Hi Iggitha,

Bear's suggestions might be preferred.

If you want to learn it the hard way,
then here we go.

Starting from a new, blank document:
Sub Test()90067
Dim strDir As String ' a folder
Dim strDoc As String ' a document
Dim strKey As String ' a keyword
Dim DcmTmp As Document ' the doc which is searched for a keyword
Dim DcmPrm As Document ' the permanent doc to collect the results
Set DcmPrm = ActiveDocument
' make sure it is empty !

strKey = InputBox("keyword to search for")
strDir = "c:\test\word1\" ' fixed folder !
strDoc = Dir(strDir & "*.doc")
While strDoc <> ""
Set DcmTmp = Documents.Open(strDir & strDoc)
With DcmTmp.Range.Find
.Text = strKey
If .Execute Then
DcmPrm.Range.InsertAfter _
strKey & " was found in " & DcmTmp.FullName & vbCrLf
End If
End With
DcmTmp.Close
strDoc = Dir()
Wend

End Sub

There is a lot of flickering on the screen, despite of
Application.ScreenUpdating = False

But doesn't matter here, I think.

Note that this searches the document's main story.
Searching *all* of the doc, headers end footers,
text boxes, captions, whatsoever,
would be a quite different story.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Re: Macro to Search for Keyword in Files by Iggitha

Iggitha
Mon Jan 07 11:05:02 PST 2008

Helmut, thanks so much! I'll give it a shot!
Iggitha

"Helmut Weber" wrote:

> Hi Iggitha,
>
> Bear's suggestions might be preferred.
>
> If you want to learn it the hard way,
> then here we go.
>
> Starting from a new, blank document:
> Sub Test()90067
> Dim strDir As String ' a folder
> Dim strDoc As String ' a document
> Dim strKey As String ' a keyword
> Dim DcmTmp As Document ' the doc which is searched for a keyword
> Dim DcmPrm As Document ' the permanent doc to collect the results
> Set DcmPrm = ActiveDocument
> ' make sure it is empty !
>
> strKey = InputBox("keyword to search for")
> strDir = "c:\test\word1\" ' fixed folder !
> strDoc = Dir(strDir & "*.doc")
> While strDoc <> ""
> Set DcmTmp = Documents.Open(strDir & strDoc)
> With DcmTmp.Range.Find
> .Text = strKey
> If .Execute Then
> DcmPrm.Range.InsertAfter _
> strKey & " was found in " & DcmTmp.FullName & vbCrLf
> End If
> End With
> DcmTmp.Close
> strDoc = Dir()
> Wend
>
> End Sub
>
> There is a lot of flickering on the screen, despite of
> Application.ScreenUpdating = False
>
> But doesn't matter here, I think.
>
> Note that this searches the document's main story.
> Searching *all* of the doc, headers end footers,
> text boxes, captions, whatsoever,
> would be a quite different story.
>
> --
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Vista Small Business, Office XP
>