From: jamesvtoomey@... (James Toomey) Date: 2004-04-15T08:39:22+09:00 Subject: Re: Sort Excel spreadsheet with Ruby? There are a few problems with the code. For one, these values: xlAscending, xlNo, xlTopToBottom are constants, but Ruby doesn't know the value of these constants because they're stored in the Excel library. Therefore, you need to substitute actual numbers for these. Here are the numeric values of those constants: xlAscending = 1, xlNo = 2, xlTopToBottom = 1 The other problem is that VBA uses named arguments, but I don't think Ruby uses named arguments; that means you can't say "Header:=xlNo". The third problem is that "Selection" is a property of the Application, not of the Sheet, so even in VBA your code failed for me. This line will work for your code: excel.Selection.Sort(sheet.Range("A1")) However, that uses all the default values. I'm still trying to figure out how to incorporate all the arguments of the Sort routine, but I suspect that you need to pass blanks for the unneeded arguments, and you definitely need to pass actual numbers in places of the Excel constants. Here's the Sort routine: ..Sort(Key1, Order1, Key2, Type, Order2, Key3, Order3, Header, OrderCustom, MatchCase, Orientation, SortMethod, IgnoreControlCharacters, IgnoreDiacritics, IgnoreKashida) The working code will probably look something like this: excel.Selection.Sort(sheet.Range("A1"), 1, '','','','','',2, 1, False, 1)