Board index » delphi » Problem with Excel 97 and Range.Sort method

Problem with Excel 97 and Range.Sort method

Hi,

Using Delphi3 I have problems using the Sort method of Range object.
Currently I use:

Range[aRange].Sort(<parameters>)

, but I always get the error: "The Sort method of Range object has errors".
I suspect that I do some errors with the parameters, have you the right
sintax with the right parameters of the Sort method ?

Thanks in advance
Stefano

 

Re:Problem with Excel 97 and Range.Sort method


<<Stefano:
have you the right sintax with the right parameters of the
Sort method ?

Quote

The Sort method is annoying - some of the parameters that
should be optional, aren't.

  WS.Range['A1', 'I10'].Sort(
     WS.Range['A1', 'A10'], xlAscending, EmptyParam,      
     EmptyParam, xlDescending,
     EmptyParam, xlAscending, xlNo, EmptyParam,
     True, xlTopToBottom, xlSyllabary);

But you can always cheat and use a variant:
var
  Rng: OleVariant;
begin
  Rng := WS.Range['A1', 'I10'];
  Rng.Sort(WS.Range['A1', 'A10']);

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Problem with Excel 97 and Range.Sort method


Quote
Deborah Pate (TeamB) wrote in message ...

>The Sort method is annoying - some of the parameters that
>should be optional, aren't.

>  WS.Range['A1', 'I10'].Sort(
>     WS.Range['A1', 'A10'], xlAscending, EmptyParam,
>     EmptyParam, xlDescending,
>     EmptyParam, xlAscending, xlNo, EmptyParam,
>     True, xlTopToBottom, xlSyllabary);

>But you can always cheat and use a variant:
>var
>  Rng: OleVariant;
>begin
>  Rng := WS.Range['A1', 'I10'];
>  Rng.Sort(WS.Range['A1', 'A10']);

Thanks a lot, both work correctly.
Stefano

Other Threads