View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default Sort method from Javascript automation

I found that using "" for the type argument seemed to work, i.e., column s
sorted.

My code:
excelapp = new ActiveXObject("Excel.Application");
excelapp.visible = true;
excelapp.workbooks.open ("c:\myfile.xls");
xl=excelapp.activesheet;
myrange = xl.range("A1:C6");
myrange.sort(xl.columns(1),1,xl.columns(2),"",1,xl .columns(3),1,1,1,0,1);

--
Jim
"smr78" wrote in message
...
| Hi,
| I try to sort a worksheet range with 3 criterias as allowed by Sort method
| programmed in Javascript.
| The problem is that the sort is performed on the first and third criteria
| but not performed on the second criteria.
| As I read on an older post, there is the same problem with Vbscript as the
| second criteria is not taken into account when there are 3 criterias.
| My simplified code is :
|
| excelapp = new ActiveXObject("Excel.Application");
| excelapp.workbooks.open (myfile.xls);
| excelapp.activeworkbook.worksheets(mysheetname).se lect();
| xl=excelapp.activesheet;
|
myrange.sort(xl.columns(1),1,xl.columns(2),null,1, xl.columns(3),1,1,1,0,1);
|
| Referring to the short Sort method arguments list :
| expression.Sort(Key1, Order1, Key2, Type, Order2, Key3, Order3, Header,
| OrderCustom, MatchCase, Orientation, SortMethod)
| it seems that the Type argument is not well passed to Excel, since the
| following code is effective :
| myrange.sort(xl.columns(1),1,xl.columns(2));
|
| As soon the Type argument is listed, the second column is not sorted.
|
| Could someone knows how to pass the Type argument?
| The null and "" values are the only values accepted in my tests. An empty
| value (as in VBscript) is not accepted.
|
| Thank you for any help.