Jump to content
Sign in to follow this  

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

Recommended Posts

This works:


But this dont:

$Range[0] = '$oExcel.Application.ActiveSheet.Range("A2:K9")'
$Range[1] = '$oExcel.Application.ActiveSheet.Range("A12:K19")'

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

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.

Share this post

Link to post
Share on other sites

I think you didnt get what i was trying to do or i didnt explain it right. Anyway - i found how to do it :


I had forgotten the execute command and couldnt find it , but eventually i did.


Here is what i wanted to do:

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


Edited by Juvigy

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  

  • Create New...