Name index sort

G

George

(word 2000)

I have a name index that has the fellowing:

George Snith 100

I wouel need the index to be like this:

Smith George 100

How do I get index to sort by last name first?

This is a large index.
 
J

Jay Freedman

(word 2000)

I have a name index that has the fellowing:

George Snith 100

I wouel need the index to be like this:

Smith George 100

How do I get index to sort by last name first?

This is a large index.

The Index Entry (XE) fields in the body of the document have to be written that
way. The Index field that collects and displays the entries doesn't have any way
to do it if the XE fields are wrong.

I gather that the Index Entry fields have already been inserted in this large
document, so reversing the names by hand would be a big job. The following macro
can help, with one restriction (see http://www.gmayor.com/installing_macro.htm
if needed):

Sub ReverseNames()
Dim oRg As Range
ActiveWindow.View.ShowHiddenText = True
Set oRg = ActiveDocument.Range
With oRg.Find
.MatchWildcards = True
.Text = "(XE \" & Chr(34) & ")([! ]@) ([! ]@)(\" & Chr(34) & ")"
.Replacement.Text = "\1\3 \2\4"
.Execute Replace:=wdReplaceAll
End With
ActiveWindow.View.ShowHiddenText = False
ActiveDocument.Fields.Update
End Sub

The restriction is that the macro can deal only with names that are two pieces,
like George Smith or Abraham Lincoln. As it is, it won't touch names with three
or more pieces, such as "Ludwig van Beethoven" or "John F. Kennedy". To make
that kind of name usable, you must edit the XE fields to put a nonbreaking space
(Ctrl+Shift+spacebar) between the parts that should stay together, and leave
only one regular space between the groups that will be reversed. In the
examples, you would replace the space between "van" and "Beethoven" with a
nonbreaking space, and you would replace the space between "John" and "F." with
a nonbreaking space, so the macro would reverse them to "van Beethoven Ludwig"
and "Kennedy John F.".
 
G

George

Jay,

This is what I throught but I wanted to be sure.
--
Thank you for your time and help.

George


Jay Freedman said:
(word 2000)

I have a name index that has the fellowing:

George Snith 100

I wouel need the index to be like this:

Smith George 100

How do I get index to sort by last name first?

This is a large index.

The Index Entry (XE) fields in the body of the document have to be written that
way. The Index field that collects and displays the entries doesn't have any way
to do it if the XE fields are wrong.

I gather that the Index Entry fields have already been inserted in this large
document, so reversing the names by hand would be a big job. The following macro
can help, with one restriction (see http://www.gmayor.com/installing_macro.htm
if needed):

Sub ReverseNames()
Dim oRg As Range
ActiveWindow.View.ShowHiddenText = True
Set oRg = ActiveDocument.Range
With oRg.Find
.MatchWildcards = True
.Text = "(XE \" & Chr(34) & ")([! ]@) ([! ]@)(\" & Chr(34) & ")"
.Replacement.Text = "\1\3 \2\4"
.Execute Replace:=wdReplaceAll
End With
ActiveWindow.View.ShowHiddenText = False
ActiveDocument.Fields.Update
End Sub

The restriction is that the macro can deal only with names that are two pieces,
like George Smith or Abraham Lincoln. As it is, it won't touch names with three
or more pieces, such as "Ludwig van Beethoven" or "John F. Kennedy". To make
that kind of name usable, you must edit the XE fields to put a nonbreaking space
(Ctrl+Shift+spacebar) between the parts that should stay together, and leave
only one regular space between the groups that will be reversed. In the
examples, you would replace the space between "van" and "Beethoven" with a
nonbreaking space, and you would replace the space between "John" and "F." with
a nonbreaking space, so the macro would reverse them to "van Beethoven Ludwig"
and "Kennedy John F.".

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
 
Top