Jump to content
Sign in to follow this  

Error with Excel UDF

Recommended Posts


Hey everyone,

I'm running into the same error over and over again, no matter what I try. I simply want to use the _ExcelSheetUsedRangeGet() function from the ExcelCOM_UDF in this little script:

Func _opentextfile()
$oExcel = _ExcelBookOpenTxt("C:\script.txt", ",", 1, 1, -4142, False, 1)
$array = _ExcelSheetUsedRangeGet($oExcel, 1)
MsgBox(0, "Test", "There are " & $array[2] & " columns in the excelfile")

Converting the textfile to an excelfile works perfectly and any other function from the ExcelCOM_UDF file works too. But even before the Messagebox can pop up, the console gives the following error:

C:\Program Files\AutoIt3\Include\ExcelCOM_UDF.au3 (2303) : ==> Subscript used with non-Array variable.:

$aSendBack[2] = Number($sTemp[1])

$aSendBack[2] = Number($sTemp^ ERROR

->12:31:18 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 3.262

I've tried downloading the UDF file again to see if that would help, but I still get the error so nothing seems to be wrong with it. What am I missing or doing wrong? The created excelfile contains 6 columns and 5 rows.

Edited by Michiel78

Share this post

Link to post
Share on other sites

Any chance you are using a language other than English? The string format of an R1C1 address is different in other languages and the RegExp pattern might not get valid info in $sTemp.

Note that UDF is not actively supported anymore, since most of the functions were moved into the standard Excel.au3 UDF that now ships with AutoIt.


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

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.