Fisherman Posted January 8, 2018 Share Posted January 8, 2018 Hi all, I have spend a lot of time trying to figure out how to copy data from e.g. Excel and paste this in a cell on a webpage of my choosing. Having read a lot of the threads in here I suspect that you guys will just tell me to look in the Help function on subjects related to "_Excel" and "_IE" (which I have done). I have tried a bunch of different solutions (including record macro) but so far nothing has worked. I suspect that my problem is that "_ExcelReadCell" does not seem to actually copy the value in a way that allows me to paste it anywhere else than than Excel... (The combination of ExcelReadCell and ExcelWriteCell works when I want to copy/paste inside Excel). It would be very much appreciated if you could provide me with an actual solution as to how I copy data in a way that allows me to paste it on a website. I have spent 3 hours on this now and it seems to me that all you experts could save some time for people (and yourself) in the future by just writing the solution instead of writing "check the Help manual" again and agian.. So far I have this: ; ***************************************************************** #include <Excel.au3> Local $sFilePath1 = "I:\Dat\3935ALL\Personer\OHJ\autoIt\test.xlsx" ;This file should already exist Local $oExcel = _ExcelBookOpen($sFilePath1) If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist") Exit EndIf Local $copy = _ExcelReadCell($oExcel,5,2) Send("{CTRLDOWN}c{CTRLUP}") ;Selecting the cell in the webpage where data should be pasted MouseClick("left", 316, 346, 1, 0) Send("{CTRLDOWN}v{CTRLUP}{ENTER}") ;_ExcelWriteCell($oExcel,$copy,2,2) ; **************************************************** I used the record button to get this piece of code: Send("{CTRLDOWN}v{CTRLUP}{ENTER}") But I am a bit unsure about the robustness of doing it that way. Many thanks! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 8, 2018 Moderators Share Posted January 8, 2018 @Fisherman what version of AutoIt are you using? You appear to be using an old version of the Excel UDF. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
water Posted January 8, 2018 Share Posted January 8, 2018 If you use the latest version of AutoIt then I suggest to use function _Excel_RangeCopyPaste to copy Excel data to the clipboard. 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...
Fisherman Posted January 9, 2018 Author Share Posted January 9, 2018 @water I'm using version 3.3.6.1. I will update the software and see if that does the job. Thank you. Link to comment Share on other sites More sharing options...
water Posted January 9, 2018 Share Posted January 9, 2018 N.B.: Here you find a list of script breaking changes when moving to the latest (and greatest) version of AutoIt. 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...
Fisherman Posted January 9, 2018 Author Share Posted January 9, 2018 I have updated the code so it works in the new version or at least the ExcelOpen part. My problem is now the copy/pasting to a website. I used the the Excel_RangeCopyPaste that u suggested @water and that works fine as long as I want to copy/paste something inside of Excel. However, it does not allow me to paste data anywhere else or am I misunderstanding the code? This is what I have so far: ;Copy/paste Local $oRange = $oWorkbook.ActiveSheet.Range("B5:B5") MouseClick("left", 316, 346, 1, 0) _Excel_RangeCopyPaste($oWorkbook.ActiveSheet, $oRange, "G4") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 1", "Error copying cells." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 1", "Range 'I2:J4' successfully copied to 'G7'.") Thanks. @JLogan3o13 Link to comment Share on other sites More sharing options...
water Posted January 9, 2018 Share Posted January 9, 2018 The function allows to copy/past from a source to a target. Source can be: An Excel range or the clipboard Target can be: An Excel range or the clipboard So _Excel_RangeCopyPaste($oWorkbook.ActiveSheet, "G4") copies cell "G4" to the clipboard. The next command should then copy the clipboard to the browser. To copy the clipboard data to the browser I suggest _ClipGet and _IEFormElementSetValue Fisherman 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...
Fisherman Posted January 9, 2018 Author Share Posted January 9, 2018 Arrhh Thanks! I see what I did wrong now. I managed to use both Excel_RangeCopyPaste and _ClipGet. However, I don't see IEFormElementSetValue or even something as simple as IEAction as doing the job. The reason is that the website is quite complicated and also requires a password. Therefore, I rationalized that it would be the easiest if I could just go to the site-page that I need to be at and then from there use the "mouse" to select cells and then paste data. The problem with IEAction as I see it is that I need to specify the "object" and I just want the object to be: my mouse clicking on the already open website and then pasting. So I was thinking something like this: MouseClick("left", 316, 346, 1, 0) _IEAction($oSubmit, "paste") but obviously the $oSubmit is given me problems as I can't really define it. Is there anoter way around this? Link to comment Share on other sites More sharing options...
water Posted January 9, 2018 Share Posted January 9, 2018 Use something like this - "(...)" stands for: To be added by you WinActivate(...) ; Activate the IE window WinWaitActive(...) ; Wait until window is active MouseClick() ; Click into the input field $sClip = Clipget() ; Retrieve the data from the clipboard Send($sClip) ; Send the data to the active window 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...
Fisherman Posted January 9, 2018 Author Share Posted January 9, 2018 Perfect! I ended up using this: MouseClick("left", 316, 346, 1, 0) $sClip = Clipget() ; Retrieve the data from the clipboard Send($sClip) ; Send the data to the active window Sleep(30) MouseClick("left", 420, 345, 1, 10) ;Send("{TAB}{ENTER}") Worked like a charm Thanks (for now ) Link to comment Share on other sites More sharing options...
water Posted January 9, 2018 Share Posted January 9, 2018 😃 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