Jump to content
Sign in to follow this  
Kiti

Excel Sort

Recommended Posts

Kiti

#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...

Share this post


Link to post
Share on other sites
PsaltyDS

#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

Share this post


Link to post
Share on other sites
Kerros

@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.

Share this post


Link to post
Share on other sites
Kiti

...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) :)

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
Kiti

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.