Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Boolean Search: Word Document

Status
Not open for further replies.

MissyEd

IS-IT--Management
Feb 14, 2000
303
GB
Hi

Version: Office 97
===================

I have 130 word templates to search. I would like to create a solution in Ms Access to perform a boolean search i.e find any templates where the work Helpdesk exists and is not immediately followed by Services so basically

Helpdesk NOT "Helpdesk Services"


Any ideas ? Its making me tear my hair out!



Missy Ed - Project Manger - Bolton, UK
 
Hi Missy Ed,
You might be able to adapt the following to suit your needs, it's a bit messy but what can you expect at midnight?

Code:
Sub find_it()
Dim wd, count
Set wd = Words
ComboBox1.Clear
    With Selection
        For Each wd In Selection.Words
            count = count + 1
            If Trim(wd) = "Helpdesk" Then
                Found = True
            ElseIf Trim(wd) <> &quot;Services&quot; And Found = True Then
                ComboBox1.AddItem ActiveDocument.Name & &quot; &quot; & count
                Found = False
            End If
            
        Next
     End With
End Sub

Hope this helps
Mike [pipe]
 
Thanks, am trying it now :)


Missy Ed - Project Manger - Bolton, UK
 
Just got an error message with this line:

Set wd = Words

Runtim error 13: Type Mismatch

Any ideas ?

Missy Ed - Project Manger - Bolton, UK
 
Hi Missy Ed,
Sorry, I got to thinking about that code this morning and realised it won't work anyway, shouldn't try to code in the middle of the night, if your game try this one, hastily done though it is again.

Code:
Sub find_it2()
Dim wd As Object, counter
Set wd = Words
On Error GoTo errorhandler

ComboBox1.Clear

  For counter = 1 To ThisDocument.Words.count
    If Trim(Words(counter)) = &quot;Helpdesk&quot; And Trim(Words(counter + 1)) <> &quot;Services&quot; Then
        ComboBox1.AddItem ActiveDocument.Name & &quot; &quot; & counter
    End If
  Next
  
errorhandler:
  

End Sub
[code]

the error you were getting was because I didn't declare wd as an object, funny how some OS care and some don't, hope this one works better!

Mike [pipe]
 
ta very much :)

Missy Ed - Project Manger - Bolton, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top