Jump to content

Excel Sort


Recommended Posts

#include <ExcelCOM_UDF.au3>
WinActivate("Microsoft Excel - Book1")
$oExcel = _ExcelAttach("Microsoft Excel - Book1", "Title")
_ExcelSort($oExcel, "A", 1, 1, 25, 1, 2)

Locodarwin's UDF. I have a bunch of numbers from A1 to A25. Anyone know why they are not sorted from smallest to largest? The script looks ok to me...

Link to comment
Share on other sites

#include <ExcelCOM_UDF.au3>
WinActivate("Microsoft Excel - Book1")
$oExcel = _ExcelAttach("Microsoft Excel - Book1", "Title")
_ExcelSort($oExcel, "A", 1, 1, 25, 1, 2)

Locodarwin's UDF. I have a bunch of numbers from A1 to A25. Anyone know why they are not sorted from smallest to largest? The script looks ok to me...

...aaaaaand what happens when you run it? You didn't really post it for someone ELSE to test for you?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

@Kiti

My guess is that AutoIT is not attaching to the Excel file. Place an _ExcelWriteCell("Test",2,2) after the attach and you will see that it's not attaching.

Now WHY it's not attaching is something I haven't figured out.

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Link to comment
Share on other sites

...aaaaaand what happens when you run it? You didn't really post it for someone ELSE to test for you?

Anyone know why they are not sorted

I think I said what happens... they are not sorted?... Yes, this happens!

@Kiti

My guess is that AutoIT is not attaching to the Excel file. Place an _ExcelWriteCell("Test",2,2) after the attach and you will see that it's not attaching.

Now WHY it's not attaching is something I haven't figured out.

It's actually attaching. The "Test" is there on B2 when I run it. There is something wrong with the Sort function I think (in my script) :)
Link to comment
Share on other sites

I think I said what happens... they are not sorted?... Yes, this happens!

It's actually attaching. The "Test" is there on B2 when I run it. There is something wrong with the Sort function I think (in my script) :)

More specifically, _ExcelSort() returns 0 and sets @error if things go wrong, you should also see errors on the SciTE console if an object call failed. What were those results?

:P

Edit: Catching errors in _ExcelSort():

#include <ExcelCOM_UDF.au3>
WinActivate("Microsoft Excel - Book1")
$oExcel = _ExcelAttach("Microsoft Excel - Book1", "Title")
$iRET = _ExcelSort($oExcel, "A", 1, 1, 25, 1, 2)
$iErrSav = @error
$iExtSav = @extended
If $iRET Then
    MsgBox(64, "Success", "Success")
Else
    MsgBox(16, "Error", "Error: $iRET = 0, @error = " & $iErrSav & ", @extended = " & $iExtSav)
EndIf
Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...