- I've made an attempt at copying cells from one sheet to another, below, with/without using the clipboard. But it's possible that the script could be improved.
Code: Select all
q:: ;Excel - copy and paste with/without the clipboard attempts
oXl := ComObjCreate("Excel.Application")
oXl.Visible := True
oXl.Workbooks.Add
;populate Sheet1 with cell with data
for oCell in oXl.Sheets("Sheet1").Range("A1:B2")
oCell.Value := oCell.Address(0, 0)
;copy cells to Sheet2 via copy and paste
oXl.Sheets("Sheet1").Range("A1:B2").Copy
oXl.Sheets("Sheet2").Paste
oXl.Application.CutCopyMode := False
;attempt to copy cells to Sheet3 without using the clipboard
for oCell in oXl.Sheets("Sheet1").Range("A1:B2")
{
oXl.Sheets("Sheet3").Range(oCell.Address).Formula := oCell.Formula
oXl.Sheets("Sheet3").Range(oCell.Address).NumberFormat := oCell.NumberFormat
oXl.Sheets("Sheet3").Range(oCell.Address).Interior.ColorIndex := oCell.Interior.ColorIndex ;highlight colour
}
oXl := ""
return