zenAngler Posted March 18, 2013 Share Posted March 18, 2013 Guys, In learning AutoIT I have been watching YouTube tutorials and experimenting primarily with Excel. I'm very excited imagining ways in which this program will help me. The one thing that I have not been able to do is a copy from Excel and paste into a new document in MS Word 2010. Using the code below I can get 20 random numbers inserted in Column B in Excel, now I want to copy those same numbers and paste them into Word. Can anyone give me a suggestion about how that is done? I tried experimenting with a lot of different commands like getClipboard and Send and none of it seemed to get the job done. Thanks very much. #include <Excel.au3> Local $oExcel = _ExcelBookNew() ;Create new Excel workbook _ExcelSheetDelete($oExcel, "Sheet2") ;Deletes Sheet2 _ExcelWriteCell($oExcel, "I Wrote to This Cell", 1, 1) ;Write to the cell into R1C1 $ColA = $oExcel.Columns("A");get the column 1 $ColA.ColumnWidth = 20; set width to 40 for the column 1 _ExcelWriteCell($oExcel, "Next Msg", 2, 1) ;Write to Cell A2 [R2C1] _ExcelWriteCell($oExcel, Random(10, 100, 1), 3, 1) ;Write a random number between 10 and 100 to Cell A3 ;Inserting random numbers down a column in Excel For $i = 0 To 20 ;Loop _ExcelWriteCell($oExcel, Random(10, 100, 1), $i, 2) ;Write a random number between 10 and 100 to Cell B1:B20 Next _ExcelWriteFormula($oExcel, "=Sum(R1C2:R20C2)", 22, 2) ;Totals the numbers in column B Local $sFormat = "$#,##0.00" ;Format String tells _ExcelNumberFormat to make it a $ currency _ExcelNumberFormat($oExcel, $sFormat, 22, 2, 22, 2) ;Start on Row 22, Start on Column 2, End on Row 22, End on Column 2 Sleep(6000) ;Pauses the spreadsheet for 6 seconds _ExcelBookClose($oExcel, 1, 0) ;This method will close the file without any of the normal prompts, regardless of changes Link to comment Share on other sites More sharing options...
water Posted March 18, 2013 Share Posted March 18, 2013 Welcome to AutoIt and the forum!There has been a similar discussion lately which can be found If you search the forum for "copy Excel Word" in titles only you will find a lot of other threads. 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