#1   Report Post  
zalek
 
Posts: n/a
Default Indexing Problem

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

  #2   Report Post  
Cindy Meister
 
Posts: n/a
Default

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

"zalek" wrote:

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


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Textboxes Gary McGill Page Layout 10 March 31st 05 03:23 PM
Indexing a document:Possible formatting problem Dave Neve Microsoft Word Help 9 March 23rd 05 09:54 PM
Attaching Expansion Pack to Word Documents - Puzzling Problem Jose Microsoft Word Help 1 March 3rd 05 10:14 AM
Word User Network Problem Alpine Tom Microsoft Word Help 1 December 17th 04 04:51 PM
Indexing problem... Phillip Tables 1 November 8th 04 08:55 PM


All times are GMT +1. The time now is 08:17 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"