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.
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)
fam = Trim(Right(x, i))
If i < Len(x) Then
fore = Trim(Left(x, Len(x) - i))
fam = fam & ", " & fore
if HasUnoInterfaces(oString,"com.sun.star.text.XTextRange") Then
oText.InsertTextContent(oString, oIndex, False)
Dim oSelction as Object
Dim oIndex as Object
Dim oDoc as Object
Dim oText as Object
Dim oVC as Object