fx11 Posted January 9, 2014 Share Posted January 9, 2014 Hi, members! I have just started learning about making AutoIt scripts. I would like to copy datas from one Excel file to another. I use Excel 2003. I have two files named: MyExFile1.xls and MyExFile2.xls First I open all the two files manually. MyExFile1.xls is the active window. When I use WinActivate("MyExFile2.xls") function in a script, it does not make switch from MyExFile1.xls to MyExFile2.xls. MyExFile1.xls stays the active window and MyExFile2.xls DOES NOT become active. How can I solve this? Thanks. Link to comment Share on other sites More sharing options...
Solution michaelslamet Posted January 9, 2014 Solution Share Posted January 9, 2014 Hi fx11, Welcome to the forum! Because "MyExFile2.xls" is not the exact title of the window. It might be something like: Microsoft Excel 2003 - MyExFile2.xls And read about Opt("WinTitleMatchMode") Link to comment Share on other sites More sharing options...
fx11 Posted January 9, 2014 Author Share Posted January 9, 2014 Hi michaelslamet! Thanks for your help. Now it works as I wish. And it does it relatively fast. Here is what I've tried: contents of MyExFile1.xls in column A:1 2 3 4 contents of MyExFile2.xls in column A:828210 828211 828212 828213 828214 828215 828216 828217 828218 828219 828220 --------------------------------------------------------------------------------My Script: AutoItSetOption("WinTitleMatchMode", 2) ;2 = Match any substring in the title WinActivate("MyExFile1.xls") WinWaitActive("MyExFile1.xls") Send("btype") Send("{ENTER}") WinActivate("MyExFile2.xls") WinWaitActive("MyExFile2.xls") Send("ordnum") Send("{ENTER}") --------------------------------------------------------------------------------Results after running it: contents of MyExFile1.xls in column A:btype 2 3 4 contents of MyExFile2.xls in column A:ordnum 828211 828212 828213 828214 828215 828216 828217 828218 828219 828220 Link to comment Share on other sites More sharing options...
michaelslamet Posted January 9, 2014 Share Posted January 9, 2014 Send is not reliable. I suggest you using Excel UDF by water. Search this forum and you will find it Link to comment Share on other sites More sharing options...
water Posted January 9, 2014 Share Posted January 9, 2014 In my signature you'll find the link to the rewrite of the Excel UDF (this will become part of the next AutoIt version). Function _Excel_RangeCopyPaste should allow to copy a range of cells from one workbook to another. See example 2 in the example 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...
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