SorryButImaNewbie

[SOLVED] Another "Array variable has incorrect number of subscripts or subscript dimension range exceeded"

22 posts in this topic

#1 ·  Posted (edited)

Hello!

Sorry for the weekly simpleton question, but:

I tried to make a part of my code be able to handle arrays of any size (Before, I used a fixed array size of 4, which is far from ideal, I just wanted it to run)

I szccesfully read the array size, ReDim it and I thought that I can easly read the values I need, but the 5. version of my code is giving me the same error. I'm not sure, how should I use variabels as "array subscripts" (I mean: $Array[!This for example!][!Or this!])

I wrote the following abomination, Its job would be to read through an array of running/open excel instances and find the one with a .xls extension. Then read its filepath and name  so I can make a copy of it a bit down on the line (BTW Anyother insight if you think I'm doing something wrong or not idealy is welcome!) 

Local $aWorkBooks = _Excel_BookList()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookList Example 2", "Error listing Workbooks." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aWorkBooks, "Excel UDF: _Excel_BookList Example 2 - List of workbooks of all instances")

;CONSTRUCTION-----------------------------------
;$aWorkBooks array méretezés
If IsArray($aWorkBooks) Then
    ReDim $aWorkBooks[UBound($aWorkBooks)]
    ;MsgBox($MB_SYSTEMMODAL, "Értesítás", "Cucc:" & UBound($aWorkBooks) & "")
    Local $ArrayElement = UBound($aWorkBooks)
    Do
        Local $Int = Int(0)
        ;MsgBox($MB_SYSTEMMODAL, "Értesítés", "Cucc: " & $ArrayElement &" Int: " & $Int &"")
        Local $Array = $aWorkBooks[Int($Int)][1]
        Local $xls = StringRegExp(String($Array), ".xls")
        $Int = Int($Int + 1)
    Until $xls = 1
    $ExcelName = $aWorkBooks[$Int][1]
    $ExcelPath = $aWorkBooks[$Int][2]
Else
    MsgBox($MB_SYSTEMMODAL, "Excel Array Hiba", "Hiba a formázandó excel felismerése közben.")
    Exit
EndIf

Consol Error:

(242) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

Local $Array = $aWorkBooks[Int($Int)][1]
Local $Array = ^ ERROR

I try to use an increasing variable to read the array until its find the .xls extension, the values of $Int is okey according to the message boxes

Thanks for the help, wise users of this forum!

Edit:

You find the solution to this problem in the thread below, also the problem developed into an other one, _Excel_SheetList UDF returned with a "funny array" with numbers (see the pic around comment 5-8) the solution was to disable excel addons: Analysis ToolPak and Solver, not sure which one did the trick at the end. Also in this thread you can find a "bug fix" for _Excel_SheetList , in the current version, _Excel_SheetList gave 0 return to every error, master water posted a fix to that (you have to change a 0 value to @error).

Best of luck!

Edited by SorryButImaNewbie
Because the problem blossomd in to a new one, I edit this so others with similar problems may benefit

Share this post


Link to post
Share on other sites



You ReDim a 2D array to a 1D array with this statement

ReDim $aWorkBooks[UBound($aWorkBooks)]

Drop this statement as I do not see any need for it in your script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ohhh, sounds logical, since I only "read in" the array once, I only need to know its size... And yes, its not a 1D array as I display it and can clearly see...

Thank you master water, I also moved the $int = 0 out from the loop, so its value doesnt jump on 1 to 0 making an infinite loop :D (thats help to)

My code right now:

Local $aWorkBooks = _Excel_BookList()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookList Example 2", "Error listing Workbooks." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aWorkBooks, "Excel UDF: _Excel_BookList Example 2 - List of workbooks of all instances")

;CONSTRUCTION-----------------------------------
;$aWorkBooks array méretezés
If IsArray($aWorkBooks) Then
    ;ReDim $aWorkBooks[UBound($aWorkBooks)]
    ;MsgBox($MB_SYSTEMMODAL, "Értesítás", "Cucc:" & UBound($aWorkBooks) & "")
    Local $ArrayElement = UBound($aWorkBooks)
    Local $Int = Int(0)
    Do
        ;MsgBox($MB_SYSTEMMODAL, "Értesítés", "Cucc: " & $ArrayElement &" Int: " & $Int &"")
        Local $Array = $aWorkBooks[Int($Int)][1]
        Local $xls = StringRegExp(String($Array), ".xls")
        $Int = $Int + 1
        If $xls = 1 Then
            Global $ExcelName = $aWorkBooks[Int($Int)][1]
            Global $ExcelPath = $aWorkBooks[Int($Int)][2]
        EndIf
    Until $xls = 1
Else
    MsgBox($MB_SYSTEMMODAL, "Excel Array Hiba", "Hiba a formázandó excel felismerése közben.")
    Exit
EndIf
;_Excel_SheetCopyMove
;----------------------------------------------

$ExcelObject = _Excel_BookAttach($ExcelName, "filename")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example 2", "Error attaching to '" & $ExcelObject & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

$ExcelSheetListArray = _Excel_SheetList($ExcelObject)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetList Example 1", "Error listing Worksheets." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
;_ArrayDisplay($ExcelSheetListArray, "Excel UDF: _Excel_SheetList Example 1")
$ExcelSheetListArrayMaxIndex = _ArrayMaxIndex($ExcelSheetListArray)

Local $oCopiedSheet = _Excel_SheetCopyMove($ExcelObject,Default,Default,Number(($ExcelSheetListArrayMaxIndex+2)),True,True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove", "Error copying sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

Local $aWorkBooks = _Excel_BookList()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookList Example 2", "Error listing Workbooks." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

I'm getting a new error: (pic added)

I belive Its an error for _Excel_SheetCopyMove, according to help: 

5 - Error occurred when copying/moving the sheet. @extended is set to the COM error code. 

Com error: 0

I aslo added extra code to my snipet, because I realized, the error giving part isn't here, so its makes any rescu attempt a "bit tricky".

Képkivágás.JPG

Edited by SorryButImaNewbie
Missing code with the error...

Share this post


Link to post
Share on other sites

This might be a bug in the UDF. Which version of AutoIt do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

3.3.14.1 right now

Share this post


Link to post
Share on other sites

You need to change the marked line in function _Excel_SheetCopyMove in Excel.au3 to get the COM error code.

If $bCopy Then
        $vSourceSheet.Copy($vBefore, $vAfter)
    Else
        $vSourceSheet.Move($vBefore, $vAfter)
    EndIf
    If @error Then Return SetError(5, @error, 0) ; <== Modify

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ohhh, to what? (I thought the error = 0)

 

So I tried to overwrite excel.au3, but I can't, only with different name (SciTE error)

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

It's a bug so it does not report @error correctly.

Now it is:

If @error Then Return SetError(5, 0, 0)

but it needs to be:

If @error Then Return SetError(5, @error, 0)

 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I understand that, but when I try to save it with 0 replaced by @error , I get an error (pic)

What i think I can do, is to rename it to excel2.au3 or something, and then simply #include that?

(Sorry I like to make sure before I do something I dont understand instead of try and make things worse :) )

Képkivágás2.JPG

Share this post


Link to post
Share on other sites

You do not have write permission to this directory where AutoIt is installed.
Either edit the file as administrator or copy the following code to your script

Func _Excel_SheetCopyMoveEX($oSourceBook, $vSourceSheet = Default, $oTargetBook = Default, $vTargetSheet = Default, $bBefore = Default, $bCopy = Default)
    ; Error handler, automatic cleanup at end of function
    Local $oError = ObjEvent("AutoIt.Error", "__Excel_COMErrFunc")
    #forceref $oError
    Local $vBefore = Default, $vAfter = Default
    If Not IsObj($oSourceBook) Or ObjName($oSourceBook, 1) <> "_Workbook" Then Return SetError(1, 0, 0)
    If $vSourceSheet = Default Then $vSourceSheet = $oSourceBook.ActiveSheet
    If $oTargetBook = Default Then $oTargetBook = $oSourceBook
    If Not IsObj($oTargetBook) Or ObjName($oTargetBook, 1) <> "_Workbook" Then Return SetError(2, 0, 0)
    If $vTargetSheet = Default Then $vTargetSheet = 1
    If $bBefore = Default Then $bBefore = True
    If $bCopy = Default Then $bCopy = True
    If Not IsObj($vSourceSheet) Then
        $vSourceSheet = $oSourceBook.Sheets($vSourceSheet)
        If @error Or Not IsObj($vSourceSheet) Then SetError(3, @error, 0)
    EndIf
    If Not IsObj($vTargetSheet) Then
        $vTargetSheet = $oTargetBook.Sheets($vTargetSheet)
        If @error Or Not IsObj($vTargetSheet) Then SetError(4, @error, 0)
    EndIf
    If $bBefore Then
        $vBefore = $vTargetSheet
    Else
        $vAfter = $vTargetSheet
    EndIf
    If $bCopy Then
        $vSourceSheet.Copy($vBefore, $vAfter)
    Else
        $vSourceSheet.Move($vBefore, $vAfter)
    EndIf
    If @error Then Return SetError(5, @error, 0)
    If $bBefore Then
        Return $oTargetBook.Sheets($vTargetSheet.Index - 1)
    Else
        Return $oTargetBook.Sheets($vTargetSheet.Index + 1)
    EndIf
EndFunc   ;==>_Excel_SheetCopyMoveEX

and replace all function calls to _Excel_SheetCopyMove to _Excel_SheetCopyMoveEX so the modified version gets called.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Wow, thanky you so much!

Can I   "Replace owner on subcontainers and objects"  on the folder? Or thats not a good idea? (I try to run as administrator, but I can't, I even tried to make a sgortcut for excel.au3, so I can use the properties/shortcut/advanced to run as admin, but I dont seems to have admin rights for that (its greyed out) which is actually pretty disturbing now that I think about it

Edit:

I tried to run your code, I get an @error = 5, @extended = 1 error on sheet copying

Edit2:

I found @extended = 1 to be the error of Read-only excel object at book_attach, I'm not sure if thats the reason here as well

Edited by SorryButImaNewbie
I save my advantures here instead of posting extras

Share this post


Link to post
Share on other sites

Did you check that all parameters for _Excel_SheetCopyMove have sensible values?
Does $ExcelSheetListArrayMaxIndex hold a sensible value (means the number of a worksheet that exists)?  I'm not sure as you add 2 to the maximum number returned by _ArrayMaxIndex. If you have 5 worksheets in your workbook thn this value shouldn't be > 5.
Use ConsoleWrite/MsgBox to display this values to check.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

According to MsgBox checks, yes, it had a value 1, 1+2 = 3 I had 3 sheets.

I tried Default value, same outcome.

The suspicous part for me is the Excel_SheetList, I displayed that during checking and it returned this, again I have 3 Sheets, none of them can be found in this list.

 

Képkivágás3.JPG

Edit: Also the $ExcelSheetListArrayMaxIndex value is 1. Which doesn't really make sense to me

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

Strange.
Which version of Office do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I'm not sure.

I have a 2016 "unoffical" version.

Now that I started digging, I found a Shortcut at C:\ProgramData\Microsoft\Windows\Start Menu\Programs, which seems to lead into itself (open containing folder), maybe because its the Start Menu folder

I'm not sure actually (I use it for maybe 2-3 years) according to office download I have an up to date version.

Will Edit for more info

Edit:

Well I may spend some time to install a real office... I'm still a student so I should be able to get a fre copy somehow, but downloading it from a "third party" was much quicker, when I only needed it for some school stuffs and basic use. It was much easier for my younger self...

Thy for the troubelshooting master water!

(verziószám = versionnumber)

Officeversionnumber.JPG

Edit2: I had a windows update, hoped it will solve the problem, it didn't this is my last update today, thanks for the help! (I love this forum)

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

I'm not sure it is caused by the Office version.
Does the _Excel_SheetList.au3 example script work for you? Means - IIRC - you should get 3 sheets listed.
Could it be possible that your workbook contains a lot of hidden sheets?
Are there custom made addons active? I once had problems with a badly written addon driving me crazy!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I checked for hidden sheets and looked for other VBA shenanigans, but nothing.

I don't know about custom meda addons, but i don't think so.

Excel sheet list gives an "interesting" error. @error = 2 for _Excel_BookOpen meaning 

Specified $sFilePath does not exist, I think this is because its ask for activation first. I added lines

MsgBox($MB_SYSTEMMODAL, " Stop ", "Hammer Time!") 

after the _Excel_BookOpen lines in the _Excel_BookList example, to close these (@error = 2 is avoided this way)

Returns empty array with display, picture of array and one excel (they look the same, empty without sheet, I can go to files and open recently used excels)

However! I can see these excels in System information/Softenvierment/RunningTasks I'm not sure that would usually mean that autoit should see it as well.

I try to open some excels (2 so its like the example) and try to list those, maybe It leads to something

Edit: Okey I tried the booklist example... not sheetlist, Trying with sheet list with the added HammerTime msg box to close the product activation It returns an @error = 1 , I don't know, I try to attach to an excel instance where there is something in the file, and list there... I don't understand I use _excel_SheetList in my code and worked there so far (if array dimensions and size were handeld correctly) it displayed the sheets like it should,

My other "idea" of the origin of the problem is that if I list the _Excel_BookList and display it I get back 3 extra thing. I'm not sure what are these (I wrote a script that goes trhought the array searching for -xls extension, so I can simply skip these) I know what the SOLVER is but I don't know it should be displayed by this function. (see: pic2, arraylist)

Could these XLAM files be the source of my problem to begin with? with some excel extension?

ExcelBookListTest.JPG

ArrayList.JPG

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

I have absolutely no idea what causes your problem :'(
You are sure that you attach to the correct workbook?

Or maybe the problem is caused by the missing activation?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I'm pretty sure (there are no other workbooks open, also before I started to upgrade my code to handel arrays, it attached to the workbook and formated the rows/columns inside just nice, so the script was interacting with it before).

Yes, the missing activation is a possible culprit.... You dont't think that these XLAM files are the problem?

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

According to the web:
http://pcsupport.about.com/od/fileextensions/f/xlamfile.htm

"A file with the XLAM file extension is an Excel Macro-Enabled Add-In file that's used to add new functions to Excel."

So this add-ins might influence the way Excel COM (and hence the Excel UDF) works.
You could try to deactivate the add-ins and check if that makes any difference.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

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

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      I keep losing the count of my $r varable when I go into the dropdown () function and call the same function.
      #include <Excel.au3> #include <AutoItConstants.au3> #include<GUIConstantsEx.au3> #include<EditConstants.au3> #include<GUIConstants.au3> Global $iBox, $oExcel, $oWorkbook, $r = 1, $x = 3 HowMany() Excel () Dropdown () Sleep (500) Func Dropdown () $list = GUICreate("Chart", 225, 80) $combobox = GUICtrlCreateCombo("Clinic 1", 10, 10, 120, 20) GUICtrlSetData(-1, "Clinic 2|Clinic 3|Clinic 4") $button = GUICtrlCreateButton("Select", 10, 40, 60, 20) GUISetState(@SW_SHOW) While 1 $guibox = GUIGetMsg() Select Case $guibox = $button Select Case GUICtrlRead($combobox) = "Clinic 1" GUIDelete($list) Auto () EndSelect Case $guibox = $GUI_EVENT_CLOSE EndSelect WEnd EndFunc Func HowMany() Local $iMsg While 1 ;~ Turn input into a number $iBox = Number(InputBox ("Regestration", "How Many Patients are there total?")) ;~ If user enters a string or cancels then get them to try again If $iBox = 0 Then $iMsg = MsgBox(1,'Regestration', 'Please enter a valid number') If $iMsg = 2 Then Exit Else ExitLoop EndIf WEnd EndFunc Func Excel() While ProcessExists("EXCEL.EXE") $ms = MsgBox(5,"","Process error. You have an Excel sheet open. You must close it in order to let this program work. Please close it now.") If $ms=2 Then Exit ;~ Doesn't require sleep since the script is paused by the MsgBox above ;~ Sleep(250) WEnd ;~ Shouldn't use Global Scope inside functions moved to top of script Local $sExcelFile = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsx)") If FileExists($sExcelFile) Then ;~ Shouldn't use Global Scope inside functions moved to top of script $oExcel = _Excel_Open () $oWorkbook = _Excel_BookOpen($oExcel,$sExcelFile) ;this will open the chosen xls file. Else $oExcel = _Excel_Open() $oWorkbook = _Excel_BookNew($oExcel, 2);this is here to create the xls file if it does not exist. EndIf EndFunc Func Auto() Local $aArray1 = _Excel_RangeRead($oWorkbook) ;~ If $iBox is greater than no. of rows in $aArray then $iBox equals the number of rows in $aArray If $iBox > (UBound($aArray1) - 1) Then $iBox = UBound($aArray1) - 1 For $i = 2 To UBound($aArray1) - 1 ;$i =0 Start from row A If $aArray1[$i][1] = "" Then Continueloop $sR0 = $aArray1[$i][0] ;status $sR1 = $aArray1[$i][1] ;Last Name $sR2 = $aArray1[$i][2] ;First Name $sR3 = $aArray1[$i][3] ;DOB $sR4 = $aArray1[$i][4] ;Sex $sR5 = $aArray1[$i][5] ;Mailling Address $sR6 = $aArray1[$i][6] ;Zip $sR7 = $aArray1[$i][7] ;Phone # $sR8 = $aArray1[$i][8] ;Visit Reason $sR9 = $aArray1[$i][9] ;Insurance $sR10 = $aArray1[$i][10] ;Clinic $sR11 = $aArray1[$i][11] ;Provider $sR12 = $aArray1[$i][12] ;Appt Time $sR13 = $aArray1[$i][13] ;Appt Date WinWaitActive ("Untitled - Notepad") ControlSend("Untitled - Notepad", "", "", $sR1 & ',' & $sR2 & @CR) $r += 1 If $r > $iBox Then Exit Dropdown () Next EndFunc so the second time I choose clinic 1 I want it to go to the next row which would be Champ brett in my example excel.
       
      Test.xlsx
      Example Format.xlsx
    • 31290
      By 31290
      Hi guys, 
      I'd like to write a piece of tool that would allow me to update a certain field in our Active Directory from a comma separated csv file composed like this:

      This file, automatically generated, can hold more than 10k lines.
      Thus, I need column A to be in one variable, column B in a second one and column C in a third one.
      I'm really missing this part as updating the AD is fairly easy once the 3 variable are populated. 
      I see things like this:
      Here's my attempts at the moment:
      #include <File.au3> #include <Array.au3> Global $csv_file = @DesktopDir & "\Book1.csv" Global $aRecords If Not _FileReadToArray($csv_file,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] Msgbox(0,'Record:' & $x, $aRecords[$x]) ; Shows the line that was read from file $csv_line_values = StringSplit($aRecords[$x], ",",1) ; Splits the line into 2 or more variables and puts them in an array ; _ArrayDisplay($csv_line_values) ; Shows what's in the array you just created. ; $csv_line_values[0] holds the number of elements in array ; $csv_line_values[1] holds the value ; $csv_line_values[2] holds the value ; etc Msgbox(0, 0, $csv_line_values[1]) Next Any help on this please? 
      Thanks in advance
      -31290-
    • StMaSi
      By StMaSi
      So, I have a text file like this...
      "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} What I'm attempting to do is read the data from this file, into an array, and use it to create checkboxes on a form like this...
      For $cb = 0 to 4 ; line numbers $Checkbox[$cb] = GUICtrlCreateCheckbox({label}, {left}, {top}, {width}, {height}) Next However, I can't figure out how to read the file into the array so as to be able to assign the data elements appropriately. I'm obviously missing something (or more than likely more than one something), but can't figure it out.
      Can anyone assist with this?
      Thanx.
       
    • dexto
      By dexto
      Why idea why would I get an error (Autoit Beta 3.3.15.0):
      Local $json[] Local $map[] $map['test'] = 'hello' Local $array[5] = [1, 2, 3, 4, 5] $json["data"] = $map $json["data"]["arr"] = $array ConsoleWrite($json["data"]["arr"][0] & @CRLF)  
    • cookiemonster
      By cookiemonster
      Im trying to read a JSON file into an array.
       
      The JSON looks like this:
       
      { "project_info": { "project_number": "123456789", "url": "https://www.website.com", "project_id": "PRJ08", "Bucket": "Buk09" }, "client": [ { "client_info": { "id": "1:1001306455", "info": { "name": "banana" } }, "oauth_client": [ { "client_id": "1001306455694-m3h6v", "client_type": 3 } ], "a_key": [ { "key": "dkldkdkd" } ], "Avail": { "ana": { "status": 1 }, "vit": { "status": 1, "other": [] }, "ad": { "status": 2 } } }, { "client_info": { "id": "1:1838346", "info": { "name": "orange" } }, "oauth_client": [ { "client_id": "2145696315633-dmdhe", "client_type": 3 } ], "a_key": [ { "key": "osikdme" } ], "Avail": { "ana": { "status": 1 }, "vit": { "status": 1, "other": [] }, "ad": { "status": 2 } } }, ], "configuration_version": "1" } What I want to do is read it all into one single large array, can anyone help? 
      All I have so far is:
      #include "JSON.au3" #include "array.au3" $file = fileread("C:\file.json") JsonToArray($file) Func JsonToArray($JSON) $JSON = StringRegExpReplace($JSON, "[\[\]{}]", "") $sBreak = StringSplit($JSON, ",") For $a = 1 To $sBreak[0] $t = _JSONDecode("{" & $sBreak[$a] & "}") _ArrayDisplay($t, "multi " & $a & " of " & $sBreak[0]) Next EndFunc ;==>JsonToArray