Jump to content

Recommended Posts

Posted

The line i got trouble with is :

Range(Selection, Selection.End(xlDown)).Select

I tried :

$oExcel.ActiveSheet.Range($oExcel.Selection , $oExcel.Selection.End(-4121)).Select

and

$oExcel.ActiveSheet.Range(.Selection , .Selection.End(-4121)).Select

but it doesnt work.

I got errors like :

.Range($oExcel.Selection , $oExcel.Selection.End(-4121)).Select

.Range($oExcel.Selection ^ ERROR

Posted

Now I have'nt installed MSOffice, so try it yourself:

#Include <Excel.au3>
$oExcel = ObjCreate("Excel.Application")
;$oExcel.visible =1
;$oExcel.workbooks.add
With $oExcel.ActiveSheet
    .Range(.Selection , .Selection.End(-4121)).Select
EndWith

_____________________________________________________________________________

Posted

Hello Juvigy!

I found many time that errors I encountered when porting VBA to AutoIt, it was necessary to reference certain objects from $oExcel.Application. For example:

$oExcel.ActiveSheet.Range( $oExcel.Application.Selection, $oExcel.Application.Selection.End(-4121) ).Select

And as Vitas pointed out, you can use "With":

With $oExcel.Application

$oExcel.ActiveSheet.Range( .Selection, .Selection.End(-4121)).Select

EndWith

Hope this helps!

Zach...

Posted (edited)

Thank you for the pointers Guys!

Turned out you have to put the whole "path" of the object in AutoIt which is not like this in VBA:

VBA:

Range(Selection, Selection.End(xlDown)).Select

=

AutoIT

$oExcel.Application.ActiveSheet.Range($oExcel.Application.Selection , $oExcel.Application.ActiveSheet.Range("A2").End(-4121)).Select

Sometimes you can skip part of the "path" but this quite often leads to logic faults difficult to grasp.

PS. The above code selects all the used cells from a row bellow the currently selected cell.

Edited by Juvigy

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
×
×
  • Create New...