Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Long Documents / August 2005

Tip: Looking for answers? Try searching our database.

Indexing Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zalek - 11 Aug 2005 00:53 GMT
I have a .txt file - it is a book.
I have another file - it is a list of keywords I want to index in the
book. The keyword can have a few words separated by space. All keywords
are sorted in descending order - there are no duplicates.
Here is my problem:

If a keyword is "book" and another is keyword "book about VBA" -
because the keywords are sorted by descending order, first in the file
will be "book about VBA" and will be indexed. Then "book" comes and
indexes  "book about VBA".
How to tell VBA not to index words that are already indexed, that means
do not index the word "book" in  "book about VBA".

Thanks,

Zalek

Here is my code:
Sub CreateIndex()

   Dim quote As String
   Dim Keyword As String
   Dim i As Integer
   Dim j As Integer
   quote = """"
   Dim found_key As Boolean
   Dim startSearch As Long
   Dim endSearch As Long

   Close #1
   Open "C:\boss_info_index.txt" For Input As #1

   i = 0
   j = 0
   Do While Not EOF(1)    ' Loop until end of file.
      Set myRange = ActiveDocument.Content
      endSearch = myRange.End

      Input #1, Keyword

      j = 0
      i = i + 1

' this is for debugging purpose
      If i > 500 Then
         myRange.Italic = True
         Exit Do
      End If

      While myRange.Find.Execute(FindText:=Keyword, Forward:=True)

         myRange.Collapse wdCollapseEnd
         Set myIndexEntry = myRange.Fields.Add(myRange,
Type:=wdFieldIndexEntry, _
                            Text:=quote & Keyword & quote)

         startSearch = myRange.End
         startSearch = startSearch + 32
         myRange.Start = startSearch
         myRange.End = endSearch
' this is for debugging purpose
         j = j + 1
         If j > 300 Then
            myRange.Bold = True
            Exit Sub
         End If
      Wend

     
   Loop
   
   Close #1    ' Close file.
   
End Sub
Cindy Meister - 11 Aug 2005 07:47 GMT
Are you familiar with Word's built-in indexing tool: Concordance? You set up
a table with all the terms you want to have indexed, with the index text you
want to use for the term in a second column. Then you call
Insert/References/Index and Tables, and on the "Index" tab click "AutoMark".

 -- Cindy

> I have a .txt file - it is a book.
> I have another file - it is a list of keywords I want to index in the
[quoted text clipped - 70 lines]
>    
> End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.