cwoolsey Posted August 21, 2015 Share Posted August 21, 2015 I am a super noob at AutoIt so bare with me.Here is my code: ;Define the Variables entered in Previous Table $ItemOut = GUICtrlRead($ItemOutID) $NumItemOut = GUICtrlRead($NumItemOutId) $Who = GUICtrlRead($WhoId) $Where = GUICtrlRead($WhereID) ;Set the filepath to the excel documents $fPath ="P:\IT_Interns\Projects\Inventory Project\Inventory.xlsx" ;Open a specific Excel window $app = _Excel_Open() ;Wait till that window has opened and is active WinWaitActive("Excel") ;Open the workbook we are using with the given filepath $Excel = _Excel_BookOpen( $app, $fPath, Default, Default, True) Global $array = _Excel_RangeFind($Excel, $ItemOut, Default, Default, $xlWhole) $arrayData = $array[2]The problem is with the last line of code and reads: Array variable has incorrect number of subscripts or subscript dimension range exceeded.How is this possible?The array is created and assigned to _Excel_RangeFind function which returns 6 values, I am trying to only obtain the 3rd value which is the address of the specific cell, so $array[2] should access the third value in the array; but it throws the error! I ran _ArrayDisplay and it runs fine showing the full 6 values so I know the array Range Find did work and input the values. Link to comment Share on other sites More sharing options...
kaisies Posted August 21, 2015 Share Posted August 21, 2015 I would look at what _Excel_RangeFind returns when it errors, because it probably is. Link to comment Share on other sites More sharing options...
kylomas Posted August 22, 2015 Share Posted August 22, 2015 (edited) cwoolsley,The function returns a 2D array thus your subscript error. Try this$arrayData = $array[2][3] ; to get value of the cellkylomasedit: Welcome to the forum. Please use the code tags when posting code. Edited August 22, 2015 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
cwoolsey Posted August 24, 2015 Author Share Posted August 24, 2015 Thank you so much for the responses! That was exactly it I cannot believe I missed that in the AutoIt Help menu. The location of what I was looking for was in $array[0][2], I have no idea why they input all of the data within the 0th 1st part of the array, they should just put it within a 1D array but nonetheless thank you! Now I just need to find out how to parse through the data to get the next cell over. If it returns A2 I need it to receive the data within B2 cell. I'll post about that on a separate post though! Link to comment Share on other sites More sharing options...
water Posted August 24, 2015 Share Posted August 24, 2015 If you always need the content of the cell one column to the right then I would use:$vResult = $oWorkbook.Range($ItemOut).Offset(0, 1).Value My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
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