neotrio Posted August 1, 2006 Share Posted August 1, 2006 hi all, following script is supposed to sort the elements of excel sheet column. Dim $excel=ObjCreate("excel.application") $excel.visible=1 $excel.WorkBooks.Add ; Add a new workbook $excel.ActiveWorkBook.ActiveSheet.Cells(1,1).Value="hello" ; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(2,1).Value="Cello" ; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(3,1).Value="Dello" ; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(4,1).Value="Aello" ; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(5,1).Value="Bello" ; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Range("A1:A5").Select.Sort("A") $excel.ActiveWorkBook.Saved = 1 Link to comment Share on other sites More sharing options...
zfisherdrums Posted August 1, 2006 Share Posted August 1, 2006 Hello neotrio, Try this: Dim $excel=ObjCreate("excel.application") $excel.visible=1 $excel.WorkBooks.Add; Add a new workbook $excel.ActiveWorkBook.ActiveSheet.Range("A1:A5").Select $excel.ActiveWorkBook.ActiveSheet.Cells(1,1).Value="hello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(2,1).Value="Cello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(3,1).Value="Dello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(4,1).Value="Aello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(5,1).Value="Bello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Range("A1:A5").Select $Key = $excel.ActiveWorkBook.ActiveSheet.Cells(1,1) $excel.ActiveWorkBook.ActiveSheet.Range("A1:A5").Sort($Key) $excel.ActiveWorkBook.Saved = 1 Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
neotrio Posted August 1, 2006 Author Share Posted August 1, 2006 Thank you, zfisherdrums. Hello neotrio, Try this: Dim $excel=ObjCreate("excel.application") $excel.visible=1 $excel.WorkBooks.Add; Add a new workbook $excel.ActiveWorkBook.ActiveSheet.Range("A1:A5").Select $excel.ActiveWorkBook.ActiveSheet.Cells(1,1).Value="hello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(2,1).Value="Cello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(3,1).Value="Dello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(4,1).Value="Aello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Cells(5,1).Value="Bello"; Fill a cell $excel.ActiveWorkBook.ActiveSheet.Range("A1:A5").Select $Key = $excel.ActiveWorkBook.ActiveSheet.Cells(1,1) $excel.ActiveWorkBook.ActiveSheet.Range("A1:A5").Sort($Key) $excel.ActiveWorkBook.Saved = 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now