我有一个代码,与Excel 2007运行绝对好,但它不与Excel 2003运行。它给出了“complie错误”,这条线变成红色。在Excel 2003中的代码错误
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
您的建议很有帮助。谢谢。如果您需要我的任何信息,请告诉我。
这里是我的全码:
'-------------------------------------
' Create Final Report
'-------------------------------------
Sub FinalReport()
Dim thisWb As Workbook
Set thisWb = ActiveWorkbook
Dim btn, rght As Long
Dim NewWbk As String
NewWbk = "Final_Report"
' Add a new workbook
Application.Workbooks.Add
Range("A1").Select
' Rename the workbook
ActiveWorkbook.SaveAs Filename:=thisWb.Path & Application.PathSeparator & "Final_Report" & ".xls"
Windows("Tool_01082013.xls").Activate
Sheets("Reports").Activate
' select the sheet and range to be copied
Range("B2:AO34").Select
' Copy the selected range...
Selection.Copy
Workbooks("Final_Report.xls").Sheets("Sheet1").Activate
' and Paste it into the new workbook
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Windows("Tool_01082013.xls").Activate
Sheets("Reports_Month").Activate
' select the sheet and range to be copied
Range("A1:DR34").Select
' Copy the selected range...
Selection.Copy
Workbooks("Final_Report.xls").Sheets("Sheet2").Activate
' and Paste it into the new workbook
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Workbooks("Final_Report.xls").Save
Workbooks("Final_Report.xls").Close
Windows("Tool_01082013.xls").Activate
With Sheets("Reports")
.Activate
.Range("A5").Select '-- move focus to the first item
End With
End Sub
尝试用xlPasteValues和xlNone与xlPasteSpecialOperationNone – mkingston 2013-02-28 22:56:25
右更换xlValues,我搞混了版本;认为你在2007年遇到麻烦。我在2007年测试;不能在2003年测试。对不起:/ – mkingston 2013-02-28 22:59:46
虐待“选择”是邪恶的。除此之外,我会尝试从xlValues除去PasteSpecial调用的所有参数。另外,错误是什么?我在工作中离开了我的水晶球;) – ApplePie 2013-02-28 23:15:38