VBA table sort using Date fails

J

Julian Ladbury

I am sorting a table using the following parms:

excludeHeader:=True, FieldNumber:=1,
SortFieldType:=wdSortFieldDate,
sortOrder:=wdSortOrderAscending

In Word 2003 (but NOT in 2000) if there are blank lines
following the header line, the sort does nothing.

If I delete the lines and redo the sort it is fine.

If I then Undo the changes and redo the sort, it works
fine.

If I then close the file without saving changes, and then
reopen it, the sort continues to work fine. The only way
to get the problem back is to close Word entirely and
start again.

I have a doc to demonstrate this problem if anyone is
interested in investigating further.

NB Word 2000 does NOT have this problem.
 
J

Julian Ladbury

Adding the LanguageID parameter to the sort circumvents the problem.
For example:

Set curTable = ThisDocument.Tables(1)
Call curTable.Sort(excludeHeader:=True,
LanguageID:=curTable.Range.LanguageID, _
FieldNumber:=1, SortFieldType:=wdSortFieldDate,
sortOrder:=wdSortOrderAscending)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top