amb2301 Posted December 30, 2019 Share Posted December 30, 2019 Hi Friends, i am new to Autoit, i am trying to read some cells from Excel & paste the those cell values in another application, i tried to learn with online scripts, i found the below script, i tried editing that script.....but while running i am getting issues as shown in screen shots , please help me #include <ExcelCOM_UDF.au3> Local $oExcel = _Excel_Open() $oExcel = _Excel_BookOpen("\\corp.ads\users\VDIUserDataKIDC1\x173795\Desktop\TEAMS\TQ_workset creation tool\TQ_WORKSET.xlsm") $aArray = _Excel_RangeRead($oExcel, Default, "A1:A10") For $vElement In $aArray MsgBox($MB_SYSTEMMODAL,"Test",$vElement) $vElement+1 Next Link to comment Share on other sites More sharing options...
water Posted December 30, 2019 Share Posted December 30, 2019 You include the wrong UDF. Include Excel.au3. 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...
amb2301 Posted December 30, 2019 Author Share Posted December 30, 2019 (edited) Hi Water, Thank you so much for your quick reply, i tried with Excel.au3, but it shows the following error message , could you please check the screenshot & guide me Edited December 30, 2019 by amb2301 update Link to comment Share on other sites More sharing options...
water Posted December 30, 2019 Share Posted December 30, 2019 Please check the wiki for script breaking changes. Your script should look like: $oExcel = _Excel_Open() $oWorkbook = _Excel_BookOpen(..) $aArray = _Excel_RangeRead(...) Pleas check the help file for the correct parameters. 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...
amb2301 Posted December 30, 2019 Author Share Posted December 30, 2019 thank you so much water, now i can able to open that excel file #include <Excel.au3> Local $sWorkbook = "C:\New folder\TQ_WORKSET.xlsm" Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) $oWorkbook = _Excel_BookAttach($sWorkbook) Now, i will try to read the ranges from excel & paste it to my application.....will get back to you ASAP Link to comment Share on other sites More sharing options...
amb2301 Posted December 30, 2019 Author Share Posted December 30, 2019 Hi Water, i can able to read the cell values now from already opened excel files, Now, actually i need to send right arrows xx times in my application, earlier i was doing it like ControlSend("Job Creation", "", "[CLASS:SNET$combobox; INSTANCE:5]", "{right 17}") now, i tried to change it by connecting the cell values in the position of 17, so can u please help me on this part... ControlSend("Job Creation", "", "[CLASS:SNET$combobox; INSTANCE:5]", "{right $sCell}") Link to comment Share on other sites More sharing options...
water Posted December 30, 2019 Share Posted December 30, 2019 (edited) You mean you want to replace "17" with the value read from Excel cell "e19"? Then use: ..., "{" & $sCell & "}") Edited December 30, 2019 by water 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...
amb2301 Posted December 30, 2019 Author Share Posted December 30, 2019 i tried like this.... ControlSend("Job Creation", "", "[CLASS:SNET$combobox; INSTANCE:5]", "{right " & $sCell & "}") but its not working Link to comment Share on other sites More sharing options...
water Posted December 30, 2019 Share Posted December 30, 2019 Define "not working". Do you get an invalid result? Do you get no result? OTOH every function of AutoIt tells you when an error has occurred. Either by setting the return value or @error and @extended. Please check the help file how ControlSend does. 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...
amb2301 Posted December 30, 2019 Author Share Posted December 30, 2019 hi water, sorry ........i am getting error like this Link to comment Share on other sites More sharing options...
water Posted December 30, 2019 Share Posted December 30, 2019 You are sure that variable $sCell gets set by your script? 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...
amb2301 Posted December 30, 2019 Author Share Posted December 30, 2019 (edited) yes, $sCell gets set by my script i tried in following ways....if i give direct numbers then its working fine (my task is to press the right arrow xx times as per cell value in mentioned cell range) Edited December 30, 2019 by amb2301 update Link to comment Share on other sites More sharing options...
water Posted December 30, 2019 Share Posted December 30, 2019 But the error above means that the variable does not exist. So the Excel statement does not set the variable. Use ConsoleWrite("Value of $sCell:" & $sCell & ", @error " & @CRLF) after the _Excel_RangeRead statement to retrieve the current value of $sCell plus the error code of _Excel_RangeRead. 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...
BrewManNH Posted December 30, 2019 Share Posted December 30, 2019 41 minutes ago, amb2301 said: yes, $sCell gets set by my script i tried in following ways....if i give direct numbers then its working fine (my task is to press the right arrow xx times as per cell value in mentioned cell range) Please STOP posting pictures of your script. Post the script, this isn't a Photoshop forum it's a code forum. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
markyrocks Posted December 31, 2019 Share Posted December 31, 2019 it would definitely be useful to see the full script. the only way i can recreate the error is if I attempt to use the variable b4 its defined. Try doing something as simple as just declaring the variable at the top of the script and see what happens. This is probably a terrible practice but it might help track down the issue. you don't even have to give it a value just right after the include insert Global $sCell. i will say without a doubt that "{right" & $sCell & "}" is the correct way to express right key pressed a certain number of times. Without being able to see the script theres no way of knowing if you have the variable declared inside of a function and your trying to use it elsewhere, etc. or some other quirky situation that might not be completely obvious. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
amb2301 Posted December 31, 2019 Author Share Posted December 31, 2019 sorry Mr.BrewmanNH, I am new to this forum, to mention the errors i posted pics......hereafter i wont post pics😟 HI All, i m posting my full code here, please check it & help to resolve the issue... Actually i have formulated excel sheet, which calculates & shows number in cell "e15" e15 contains a numeric value, for example if e15 contains numeric value as 17, then i need to press RIGHT key in my application for 17 Times, but its not happening with my code, could anyone help me to resolve this issue... #include <Excel.au3> Local $bOpenWorkBook = False, $oExcel = _Excel_Open() Local $sWorkbook = "\\corp.ads\users\VDIUserDataKIDC1\x173795\Desktop\TEAMS\TQ_workset creation tool\TQ_WORKSET.xlsm" Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) $oWorkbook = _Excel_BookAttach($sWorkbook) Local $sCell = _Excel_RangeRead($oWorkbook, Default, "e15") ;MsgBox(4096, "Excel Cell Value", "Value = " & $sCell) WinActivate("Job Creation") ControlSend("Job Creation", "", "[CLASS:SNET$combobox; INSTANCE:5]", "0") Sleep(500) ControlSend("Job Creation", "", "[CLASS:SNET$combobox; INSTANCE:5]", "A") Sleep(2000) ;Send("{right 17}") ControlSend("Job Creation", "", "[CLASS:SNET$combobox; INSTANCE:5]", "({right " & $sCell & " })") Sleep(500) ControlSend("Job Creation", "", "[CLASS:SNET$Edit; INSTANCE:2]", "^{left}") Sleep(500) ControlSend("Job Creation", "", "[CLASS:SNET$Edit; INSTANCE:2]", "^{left}") Sleep(500) ControlSend("Job Creation", "", "[CLASS:SNET$Edit; INSTANCE:2]", "^{del}") Sleep(1000) ControlSend("Job Creation", "", "[CLASS:SNET$Edit; INSTANCE:2]", "123") Sleep(500) ControlSend("Job Creation", "", "[CLASS:Edit; INSTANCE:2]", "24242425") Sleep(500) ControlClick("Job Creation","",8434) sleep(3000) WinWait("Find View Profile", "Name") WinActivate("Find View Profile") ControlSend("Find View Profile", "", "[CLASS:SNET$Edit; INSTANCE:1]", "^a") Link to comment Share on other sites More sharing options...
markyrocks Posted December 31, 2019 Share Posted December 31, 2019 ok lol this has been pretty annoying for me tracking this down. apparently it must be an issue with controlsend(). at least thats what i gather. your syntax is wrong but your probably pulling your hair out by now. just remember dude in programming there's always more than one way to do something. just do this and be done with it. i can't take no more. for $x=1 to $sCell ControlSend("Job Creation", "", "[CLASS:SNET$combobox; INSTANCE:5]", "{RIGHT}") next Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
amb2301 Posted December 31, 2019 Author Share Posted December 31, 2019 Hi Markyrocks, it worked for me, thank you so much for your help i am so Thankfull to you 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