Juvigy Posted May 11, 2015 Posted May 11, 2015 This works:$oExcel.Application.Union($oExcel.Application.ActiveSheet.Range("A2:K9"),$oExcel.Application.ActiveSheet.Range("A12:K19")).SelectBut this dont:$Range[0] = '$oExcel.Application.ActiveSheet.Range("A2:K9")' $Range[1] = '$oExcel.Application.ActiveSheet.Range("A12:K19")' $oExcel.Application.Union($Range[0],$Range[1]).SelectHow can i make it work ?I am planning on converting the array to a string and paste it as argument of the union as the number of ranges to be combined varies.
Moderators JLogan3o13 Posted May 11, 2015 Moderators Posted May 11, 2015 Juvigy, you've been around long enough to know better than to post non-runnable code with nothing more than "it's broke" as an explanation. Why are you not using the built in Excel functions? This snippet (bare minimum since you haven't shown us what you're actually trying to accomplish) returns the ranges you're after:#include <Excel.au3> $oExcel = _Excel_Open() $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir & "\Test.xls", True) $param1 = _Excel_RangeRead($oWorkbook, Default, "A2:K9") $param2 = _Excel_RangeRead($oWorkbook, Default, "A12:K19")From there you can convert your array to a string (_ArrayToString) or manipulate however you need to. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Juvigy Posted May 11, 2015 Author Posted May 11, 2015 (edited) I think you didnt get what i was trying to do or i didnt explain it right. Anyway - i found how to do it :Execute("$oExcel.Application.Union("&$Range[0]&","&$Range[1]&").Select")I had forgotten the execute command and couldnt find it , but eventually i did.@EDITHere is what i wanted to do:$parameter = "$oExcel.Application.Union("&_ArrayToString($Range,",")&").Select" Execute($parameter) Edited May 11, 2015 by Juvigy solution
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