Sign in to follow this  
Followers 0
neotrio

code not working !

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

Thank you, zfisherdrums.:whistle:

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0