Re: Macro to Sort 5 Column Table



You don't need to worry about the end of cell marker. If you type Sort into
the Visual Basic Editor and press F1, you will get the following information

Word Developer Reference
Table.Sort Method
Sorts the specified table.
expression.Sort(ExcludeHeader, FieldNumber, SortFieldType, SortOrder,
FieldNumber2, SortFieldType2, SortOrder2, FieldNumber3, SortFieldType3,
SortOrder3, CaseSensitive, BidiSort, IgnoreThe, IgnoreKashida,
IgnoreDiacritics, IgnoreHe, LanguageID)

expression Required. A variable that represents a Table object.

Parameters

Name Required/Optional Data Type Description
ExcludeHeader Optional Variant True to exclude the first row from the
sort operation. The default value is False.
FieldNumber Optional Variant The first field by which to sort.
Microsoft Word sorts by FieldNumber, then by FieldNumber2, and then by
FieldNumber3.
SortFieldType Optional Variant The sort type for FieldNumber. Can be
one of the WdSortFieldType constants. Some of these constants may not be
available to you, depending on the language support (U.S. English, for
example) that you have selected or installed. The default value is
wdSortFieldAlphanumeric.
SortOrder Optional Variant The sorting order to use when sorting
FieldNumber. Can be a WdSortOrder constant.
FieldNumber2 Optional Variant The second field by which to sort.
SortFieldType2 Optional Variant The sort type for FieldNumber2. Can be
one of the WdSortFieldType constants. Some of these constants may not be
available to you, depending on the language support (U.S. English, for
example) that you have selected or installed. The default value is
wdSortFieldAlphanumeric.
SortOrder2 Optional Variant The sorting order to use when sorting
FieldNumber2. Can be one WdSortOrder constant.
FieldNumber3 Optional Variant The third field by which to sort.
SortFieldType3 Optional Variant The sort type for FieldNumber3. Can be
one of the WdSortFieldType constants. Some of these constants may not be
available to you, depending on the language support (U.S. English, for
example) that you have selected or installed. The default value is
wdSortFieldAlphanumeric.
SortOrder3 Optional Variant The sorting order to use when sorting
FieldNumber3. Can be one WdSortOrder constant.
CaseSensitive Optional Variant True to sort with case sensitivity. The
default value is False.
BidiSort Optional Variant True to sort based on right-to-left language
rules. This argument may not be available to you, depending on the language
support (U.S. English, for example) that you've selected or installed.
IgnoreThe Optional Variant True to ignore the Arabic character alef
lam when sorting right-to-left language text. This argument may not be
available to you, depending on the language support (U.S. English, for
example) that you've selected or installed.
IgnoreKashida Optional Variant True to ignore kashidas when sorting
right-to-left language text. This argument may not be available to you,
depending on the language support (U.S. English, for example) that you've
selected or installed.
IgnoreDiacritics Optional Variant True to ignore bidirectional control
characters when sorting right-to-left language text. This argument may not
be available to you, depending on the language support (U.S. English, for
example) that you've selected or installed.
IgnoreHe Optional Variant True to ignore the Hebrew character he when
sorting right-to-left language text. This argument may not be available to
you, depending on the language support (U.S. English, for example) that you've
selected or installed.
LanguageID Optional Variant Specifies the sorting language. Can be one
of the WdLanguageID constants. Refer to the Object Browser for a list of the
WdLanguageID constants.

Example


This example sorts the first table in the active document, excluding the
heading row.

Visual Basic for Applications
Sub NewTableSort()
ActiveDocument.Tables(1).Sort ExcludeHeader:=True
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Alan in NJ" <devildad77@xxxxxxxxxxx> wrote in message
news:eYnnX6VJIHA.5328@xxxxxxxxxxxxxxxxxxxxxxx
Rarely writing macros, I forgot how to deal with the pesky end-of-cell
mark. I need a macro to simply alphabetically sort a five-column table.
Some quick help would be appreciated.

Alan



.



Relevant Pages

  • Re: first steps with perl, a log reader
    ... Express those purposes, and the steps to achieve them, in plain language. ... With this sort of comment I wouldn't be L'ing OL at this point. ... Now here's where Perl splits people. ... 'use warnings' will give you all that you need ...
    (perl.beginners)
  • Re: Government regulations
    ... I currently am supplying boards with an annual dollar ... Anyone here have experience with this sort of thing? ... Are you contractually obliged to provide these certifications? ... development was from my customer and had no language like this. ...
    (comp.arch.embedded)
  • Re: "Whoops! Its Earth!"-noodling
    ... anemones and octopodes share a sort of sign language? ... Different methods of communication available to different creatures could be ... language with his antennae, and has sound (from rubbing bits together like ... Large land creatures will need some sort of lung-like system, ...
    (rec.arts.sf.composition)
  • Re: *Juggling anti spin*
    ... first language, so I'm probably wrong. ... much better than natives when it comes to this sort of thing. ... That's usually true for foreigners that learns English in school, ...
    (rec.juggling)
  • CL subset?
    ... language in a conscious effort to create smaller distributables. ... case of COMPILE and friends, they wouldn't be giving up much at all. ... it seems the most obvious way to implement this sort of thing is to ... LISP" question. ...
    (comp.lang.lisp)