Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Copy from Excel then Paste into Word

$
0
0
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




Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>