The purpose of this document is to provide a simple step by step way of automating
the compilation of family-name indexes. The content incluudes the basic macro code and
shows how to attach this to a speed-key so that indexing is a one key-stroke operation.
Background
When writing a family history document we often refer to, say, "John William Smith" and
would like to have this indexed as "Smith, John William". The standard indexing in Writer
will by default index "John William Smith" as "John William Smith". To change this manually to "Smith, John William"
requires some effort each time we want to index an entry. Clearly there should be a better way.
x = Trim(current)
if len(x) = 0 then exit sub
fore = ""
next_char = ""
i = 0
While next_char <> " " And i < Len(x)
i = i + 1
next_char = Left(Right(x, i), 1)
Wend
fam = Trim(Right(x, i))
If i < Len(x) Then
fore = Trim(Left(x, Len(x) - i))
fam = fam & ", " & fore
End If
if HasUnoInterfaces(oString,"com.sun.star.text.XTextRange") Then
oIndex.setMarkEntry(fam)
oText.InsertTextContent(oString, oIndex, False)
end If
End Sub
sub phrase_index
Dim oSelction as Object
Dim oIndex as Object
Dim oDoc as Object
Dim oText as Object
Dim oVC as Object
if HasUnoInterfaces(oString,"com.sun.star.text.XTextRange") Then
oIndex.setMarkEntry(x)
oText.InsertTextContent(oString, oIndex, False)
end If
end sub
The next step is to assign these macro to speed keys. {shift}{ctrl}M and {shift}{crtl}N are available unless you have already assinged something to them.
This is done by by using the Tool, Options menu and the Keyboard tab.
Select the macro first then assign it to the key by pressing the modify button.