无法访问vba另一张表

我试图访问图表和图片和另一个工作簿中存在的图表在同一个文件夹中的图表。 这是我的代码。

wbname = Worksheets("Sheet1").Range("A1:A1").Value wsname = Worksheets("Sheet1").Range("A2:A2").Value MsgBox wbname wbname = ThisWorkbook.Path & "\" & wbname MsgBox "reached here" MsgBox "HI" MsgBox Workbooks("C:\charts\1.xls").Sheet("L1-XO PGT ScoreCard").Range("A1:A1").Value Set aWorkSheet = Workbooks("C:\charts\1.xls").Sheet("L1-XO PGT ScoreCard") sCurrentSheet = aWorkSheet.Name MsgBox "Shapes count " + CStr(aWorkSheet.Shapes.Count) For iIndex = 1 To aWorkSheet.Shapes.Count Set aShape = aWorkSheet.Shapes(iIndex) MyPicture = aShape.Name MsgBox aShape.Name + " Name, " + Str(aShape.Type) If Left(aShape.Name, 7) = "Picture" Then With aShape PicHeight = .Height PicWidth = .Width End With Set aChart = ActiveWorkbook.Charts.Add ActiveWorkbook.ActiveChart.Location Where:=xlLocationAsObject, Name:=sCurrentSheet iShapeCount = aWorkSheet.Shapes.Count Set aShapeChart = aWorkSheet.Shapes(iShapeCount) MyChart = aShapeChart.Name '"Chart " & Str(aWorkSheet.Shapes.Count) aShapeChart.Width = PicWidth aShapeChart.Height = PicHeight sChartJpg = sChartJpg & aShapeChart.Name & ".jpg" With aWorkSheet aShape.Copy With ActiveChart 'aChart .ChartArea.Select .Paste End With .ChartObjects(iIndex).Chart.Export Filename:=sChartJpg, FilterName:="jpg", Interactive:=True aShapeChart.Cut End With Application.ScreenUpdating = True MsgBox "Completed." Exit Sub End If Next MsgBox "Completed."Exit Sub ErrHandler: MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description & " " & Err.Source Err.Clear ' Clear the error. End Sub 

显示“HI”提示框后,直接显示“已完成的testing箱”,不显示TestBOX提示“MsgBox Workbooks(”C:\ charts \ 1.xls“),表格(”L1-XO PGT ScoreCard“)。 (“A1:A1”)。值“…也不是从工作簿中提取图像。 有人可以帮忙

您必须打开工作簿 – 大部分代码在closures的工作簿上不起作用。