I have code that creates an Automark file. How do I use it?
Below is the code that I installed in the VB editor of Word.
When I enter a new sentence that contains a word that was previously indexed and run this code, the index at the end of the document does not reflect the word in the new sentence with the previously-indexed word.
Please help this MsWord casual user.
Dim fld As Field
Dim strText As String
Dim rw As Row
Dim tbl As Table
Dim bFound As Boolean
Dim doc As Word.Document
Dim DocA As Document
Set DocA = ActiveDocument
Set doc = Documents.Add
Set tbl = doc.Tables.Add(doc.Range, 1, 2)
For Each fld In DocA.Fields
If fld.Type = wdFieldIndexEntry Then
strText = GetIndexText(fld)
bFound = False
For Each rw In tbl.Rows
If GetCellText(rw.Cells(1)) = strText Then
bFound = True
If Not bFound Then
If Len(tbl.Rows.Last.Range) = 6 Then
Set rw = tbl.Rows.Last
Set rw = tbl.Rows.Add
rw.Cells(1).Range.Text = strText
rw.Cells(2).Range.Text = strText