我在使用其他软件将单元格从一个Excel复制粘贴到另一个Excel文件时有些挣扎。我在这里有以下代码(是我从此thread借来的):
Set objExcel = CreateObject("Excel.Application")
' Variables passed on from a software
' vTempRange is "A2:D14" and vFinalRange is something similar
vTempRange = WScript.Arguments.Item(0)
vFinalRange = WScript.Arguments.Item(1)
vReport = WScript.Arguments.Item(2)
' Open the workbook
Set x = Workbooks.Open("C:\sample.xlsx")
Set y = Workbooks.Open("C:\Final.xlsx")
' Set to True or False, whatever you like
objExcel.Visible = True
' Select the range on Sheet1 you want to copy
x.Worksheets("Sheet1").Range(vTempRange).Copy
' Paste it on Sheet2, starting at A1
y.Worksheets(vReport).Range(vFinalRange).PasteSpecial
' Activate Sheet2 so you can see it actually pasted the data
y.Worksheets(vReport).Activate
但是,这在运行其他软件时返回了424对象必需的错误。有人可以给我一些提示或解决方案吗?谢谢!