DrewSS Posted January 14, 2015 Share Posted January 14, 2015 Hello, I am having trouble upgrading AutoIT and utilizing the new Excel UDF. Below is my old code which works great (slow, but correct), but _Excel_RangeRead is not working dynamically. $oExcelM = _ExcelBookOpen($sFilePath_list_master) $aArrayM = _ExcelReadSheetToArray($oExcelM, 2) For $resultsM = 0 To UBound($aArrayM) - 1 $chainM = $aArrayM[$resultsM][3] $storeM = $aArrayM[$resultsM][4] $queueM = $aArrayM[$resultsM][9] $descriptionM = $aArrayM[$resultsM][5] $categoryM = $aArrayM[$resultsM][6] If Not ($chainM == "") Then FileWrite($sFilePath_temp_master, $chainM & "-" & $storeM & @CRLF) EndIf If ($queueM == "US_L1_Call Center System Alerts") Then FileWrite($sFilePath_temp_master, $descriptionM & @CRLF) EndIf If ($categoryM = "Zero Coups") Then If ($chainM == "") Then FileWrite($sFilePath_temp_master_zerocoups, $descriptionM & @CRLF) ElseIf Not ($chainM == "") Then FileWrite($sFilePath_temp_master_zerocoups, $chainM & "-" & $storeM & @CRLF) EndIf EndIf Next _ExcelBookClose($oExcelM) Here is the new code with _Excel_RangeRead, but the results of my array are "0" Local $oApplM = _Excel_Open() Local $oExcelM = _Excel_BookOpen($oApplM, $sFilePath_list_master) $aArrayM = _Excel_RangeRead($oExcelM, $oExcelM.ActiveSheet.Usedrange.Columns("A:Z"), 1) For $resultsM = 0 To UBound($aArrayM) - 1 $chainM = $aArrayM[$resultsM][3] $storeM = $aArrayM[$resultsM][4] $queueM = $aArrayM[$resultsM][9] $descriptionM = $aArrayM[$resultsM][5] $categoryM = $aArrayM[$resultsM][6] If Not ($chainM == "") Then FileWrite($sFilePath_temp_master, $chainM & "-" & $storeM & @CRLF) EndIf If ($queueM == "US_L1_Call Center System Alerts") Then FileWrite($sFilePath_temp_master, $descriptionM & @CRLF) EndIf If ($categoryM = "Zero Coups") Then If ($chainM == "") Then FileWrite($sFilePath_temp_master_zerocoups, $descriptionM & @CRLF) ElseIf Not ($chainM == "") Then FileWrite($sFilePath_temp_master_zerocoups, $chainM & "-" & $storeM & @CRLF) EndIf EndIf Next _Excel_BookClose($oExcelM) How can I get my values from excel with the new UDF? Link to comment Share on other sites More sharing options...
water Posted January 14, 2015 Share Posted January 14, 2015 Parameter 2 is missing. Needs to be: $aArrayM = _Excel_RangeRead($oExcelM, $oExcelM.ActiveSheet, $oExcelM.ActiveSheet.Usedrange.Columns("A:Z"), 1) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
DrewSS Posted January 14, 2015 Author Share Posted January 14, 2015 Good call, I just noticed that too. I used Default instead, which should be fine for my 1 worksheet. However, the range A:Z is not working. With only 1 column at a time I suppose I could get rid of the translation variables and just make $chainM = _Excel_RangeRead($oExcelM, $oExcelM.ActiveSheet, $oExcelM.ActiveSheet.Usedrange.Columns("C:C"), 1) (instead of $chainM = $aArrayM[$resultsM][3]) ... this may work. Unless anyone knows how to get all cells through A:Z working i'm going to change my entire program for the new structure; it just does not seem very dynamic. Link to comment Share on other sites More sharing options...
iamtheky Posted January 14, 2015 Share Posted January 14, 2015 maybe usedrange is the issue, what about just $oExcelM.Activesheet.Columns("a:z") ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
water Posted January 14, 2015 Share Posted January 14, 2015 What is the value of @error and @extended after _Excel_RangeRead? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
DrewSS Posted January 14, 2015 Author Share Posted January 14, 2015 (edited) When I use A:Z the errors are @5 and extended@-2147352571 I tried without Usedrange but that had the same error. I'm changing up all my code structure but getting rid of the For loop that cycled through the complete array with the old UDF means I need a For loop for each column now? EDIT: errors are @5 and extended@-2147352571 Edited January 14, 2015 by DrewSS Link to comment Share on other sites More sharing options...
Solution water Posted January 14, 2015 Solution Share Posted January 14, 2015 Did you have a look at the the help file? @error = 5 means: Error occurred when reading data using the transpose method. @extended is set to the COM error code Could you try: $aArrayM = _Excel_RangeRead($oExcelM, $oExcelM.ActiveSheet, $oExcelM.ActiveSheet.Usedrange.Columns("A:Z"), 1, True) DrewSS 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
DrewSS Posted January 14, 2015 Author Share Posted January 14, 2015 water!!! Your the best! Thank you! Link to comment Share on other sites More sharing options...
water Posted January 14, 2015 Share Posted January 14, 2015 The transpose method can not handle cells with more than 255 characters. That might have caused the problem. DrewSS 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - 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