Jump to content
Sign in to follow this  
Juvigy

How to use array of strings as argument of a function call

Recommended Posts

Juvigy

This works:

$oExcel.Application.Union($oExcel.Application.ActiveSheet.Range("A2:K9"),$oExcel.Application.ActiveSheet.Range("A12:K19")).Select

But 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]).Select

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

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Juvigy

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.

@EDIT

Here is what i wanted to do:

$parameter = "$oExcel.Application.Union("&_ArrayToString($Range,",")&").Select"
Execute($parameter)

 

Edited by Juvigy
solution

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  

×