Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: FoxPro FAQ

COM and Automation

Excel Automation Sort by jmcd0719
Posted: 13 Feb 04

*The documentation on sorting a table in Excel is lacking
*The syntax for using the sort object is as follows

public oleapp

*There are 12 parameters:
lkey1='oleapp.Range("a1")'  && Column you want to sort
lorder1=1   && 1 - Ascending 2 - Decending (default 1)
ltype=""   && Leave Blank (default blank)
lkey2='oleapp.Range("b1")' && Second Column (default blank)
lorder2=1  && same as above (default 1)
lkey3='oleapp.Range("c1")' && Third Column (default blank)
lorder3=1  && same as above (default 1)
lheader=1  && Does table have Header 0-Guess,1-Yes,2-No (Default 0)
&&lcustom= skip altogher
lmatch=.f. && match case .t.=Yes .f.=NO (default .f.)
&&lorient= Skip altogether
lsortmeth=1  && not sure if used (default 1)
ldataopt1=0  && Sort normally, by month, day, etc (default 0)
ldataopt2=0  && Same as opt1
ldataopt3=0  && Same as opt2

l_file="c:\test.csv"  && any file will do that opens natively in excel"
oleapp.Range(lrange).Sort(&lkey1)  && Simplest sort using defaults
&& sorting using variables
&& sorting with values

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close