我对下面的代码有几个问题。我正在将图表从一个文件复制并粘贴到另一个文件,然后关闭图表所在的文件。当我在调试器中逐步执行代码时,一切正常,但是当我使用工作表上的按钮触发该过程时,它给了我一个错误:找不到对象。
即使我正在使用Application.ScreenUpdating = False
.
任何人都可以帮忙吗?任何帮助将不胜感激!!!
谢谢
Application.ScreenUpdating = False
Windows("Overhead Display.xls").Activate
Sheets("CHART DISPLAY - FINISH").Activate
Application.DisplayFullScreen = True
ActiveSheet.ChartObjects("ChartImage").Activate
ActiveSheet.ChartObjects("ChartImage").Delete
ChDir _
"C:\...FILES"
Workbooks.Open Filename:= _
"C:\...BLACK.xls"
Sheets("RYG CHARTS").Visible = True
Sheets("RYG CHARTS").Activate
ActiveSheet.Unprotect Password:="052100F"
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
ActiveWindow.Visible = False
Windows("Overhead Display.xls").Activate
ActiveSheet.Paste
'Rename chart to delete later
ActiveChart.Parent.Name = "ChartImage"
ActiveSheet.ChartObjects("ChartImage").Activate
ActiveSheet.Shapes("ChartImage").Top = 100
ActiveSheet.Shapes("ChartImage").Width = 700
ActiveSheet.Shapes("ChartImage").Height = 375
ActiveSheet.Shapes("ChartImage").Left = 20
'ActiveWindow.Visible = False
Windows("Overhead Display.xls").Activate
Range("A1").Select
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With
Windows("BMW F25 OUTERBELT BLACK.xls").Activate
Sheets("FILE SETUP").Activate
ActiveSheet.Unprotect Password:="052100AF"
Range("J2").Select
Selection.Copy
Windows("Overhead Display.xls").Activate
Sheets("CHART DISPLAY - FINISH").Activate
Range("K2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows("BMW F25 OUTERBELT BLACK.xls").Activate
Range("J3").Select
Selection.Copy
Windows("Overhead Display.xls").Activate
Sheets("CHART DISPLAY - FINISH").Activate
Range("J3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows("BMW F25 OUTERBELT BLACK.xls").Activate
Range("D2").Select
Selection.Copy
Windows("Overhead Display.xls").Activate
Sheets("CHART DISPLAY - FINISH").Activate
Range("L4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows("BMW F25 OUTERBELT BLACK.xls").Activate
Range("D3").Select
Selection.Copy
Windows("Overhead Display.xls").Activate
Sheets("CHART DISPLAY - FINISH").Activate
Range("N3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows("BMW F25 OUTERBELT BLACK.xls").Activate
Range("H13").Select
Selection.Copy
Windows("Overhead Display.xls").Activate
Sheets("CHART DISPLAY - FINISH").Activate
Range("U11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows("BMW F25 OUTERBELT BLACK.xls").Activate
Range("F13").Select
Selection.Copy
Windows("Overhead Display.xls").Activate
Sheets("CHART DISPLAY - FINISH").Activate
Range("U13").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows("BMW F25 OUTERBELT BLACK.xls").Activate
Range("G13").Select
Selection.Copy
Windows("Overhead Display.xls").Activate
Sheets("CHART DISPLAY - FINISH").Activate
Range("U15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows("BMW F25 OUTERBELT BLACK.xls").Activate
Sheets("RAW DATA LIST").Activate
ActiveSheet.Range("A2") = ""
Windows("BMW F25 OUTERBELT BLACK.xls").Activate
ActiveWorkbook.Close SaveChanges:=False
Windows("Overhead Display.xls").Activate
Sheets("CHART DISPLAY - FINISH").Activate
Range("A1").Select
Application.ScreenUpdating = True