dm83737 Posted February 26, 2009 Share Posted February 26, 2009 Once again, I am making this harder than it needs to be, but I am trying to figure out how to simply select a cell in Excel so I can paste data copied from another application. I tried searching for "highlight cell Excel" and "Copy to cell" and many others, found information on arrays and ControlClick as well as other things and can't seem to find the answer I need. So basically I am doing the "WinMenuSelectItem($Session, "", "&Edit", "&Copy" )" to get the data, but I need a way to choose a specific cell in Excel in order to paste this information to. The roundabout solution is that I could just paste the data to Notepad, but then that would require re-work of typing them into Excel and I know AutoIT can help me avoid that. Just to make sure I am understanding this correctly, I can not assign a variable name to WinMenuSelectItem for the data it copies, can I? That would just run the Edit > Copy steps again if I noted the variable later. (i.e. - $iClientNumberCopy = WinMenuSelectItem($Session, "", "&Edit", "&Copy" ) So I guess all I need is a way to paste the data from the clipboard to a specific cell in Excel and just can't seem to find the right method. Thanks Anyway, here's my code: expandcollapse popupFor $iRowRange = 2 To 999 ; Variable definitions $sLastName = _ExcelReadCell($oExcel, $iRowRange, 1) $sFirstName = _ExcelReadCell($oExcel, $iRowRange, 2) $sSexCode = _ExcelReadCell($oExcel, $iRowRange, 3) $iDOB = _ExcelReadCell($oExcel, $iRowRange, 4) $iSSN = _ExcelReadCell($oExcel, $iRowRange, 5) $sType = _ExcelReadCell($oExcel, $iRowRange, 6) $sAddress = _ExcelReadCell($oExcel, $iRowRange, 7) $sCity = _ExcelReadCell($oExcel, $iRowRange, 8) $sState = _ExcelReadCell($oExcel, $iRowRange, 9) $iZip = _ExcelReadCell($oExcel, $iRowRange, 10) WinActivate($Session) Send("{TAB 6}") Send($sLastName) Send("{TAB}") Send($sFirstName) Send("{RCTRL}") Sleep(1000) Send("{F6}") Sleep(1000) Send("{TAB 16}") Send($sSexCode) Sleep(25) Send($iDOB) Send("{TAB}") Send($sState) Sleep(25) Send($iSSN) Send("{TAB 4}") Send($sType) Sleep(25) Send($sAddress) Send("{TAB 3}") Send($sCity) Send("{TAB}") Send($sState) Sleep(25) Send($iZip) Send("{TAB 7}") Send("N") Send("{RCTRL}") Sleep(3000) Msgbox(0, "TEST", "Enough Time?") Send("{F6}") Sleep(3000) Msgbox(0, "TEST", "Enough Time?") Send("{RCTRL}") Sleep(3000) ; Capture the client number from TRMS MouseClickDrag("left", 785, 185, 902, 195) WinMenuSelectItem($Session, "", "&Edit", "&Copy" ) ; Note the client number in Excel for future reference WinActivate($oExcel) _ExcelWriteCell($oExcel, $iClientNumberCopy, $iRowRange, 11);<===== NOT SURE WHAT TO DO HERE TO PASTE INFO INTO SPECIFIC CELL ; Resets TRMS for the next client (if present) WinActivate($Session) Send("{F4}") Sleep(1000) ; Is there a client entry to read? If _ExcelReadCell($oExcel, ($iRowRange), 2) = "" Then ExitLoop Next Link to comment Share on other sites More sharing options...
SpookMeister Posted February 26, 2009 Share Posted February 26, 2009 I'm not very familiar with the excel UDF, have never used it actually... but it surprises me that you are not referencing specific cells to place data in ... i.e. A7 B16 etc. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
SpookMeister Posted February 26, 2009 Share Posted February 26, 2009 Like with _ExcelWriteCell (I just peeked at the help file... wonderful tool) [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
junkew Posted February 26, 2009 Share Posted February 26, 2009 search for getobject or excel.application in forum FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
dm83737 Posted February 26, 2009 Author Share Posted February 26, 2009 I'm not very familiar with the excel UDF, have never used it actually... but it surprises me that you are not referencing specific cells to place data in ... i.e. A7 B16 etc.Since this is being used in a loop and the location changes each time around, I use a variable to reference the cells (i.e. - $sRowRange), the column however stays at 11. And I agree, the help file is pretty amazing, it just doesn't tell me what I am looking for here.I will try your suggestions junkew and let you know if I find something I can use. 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