1
我想创建一个图表并将其重新定位到我的PowerPoint表格上的正确位置。但收到一个运行时错误。的代码中的相关位是:重新定位图表对象VBA
(我的图表数据不在代码)
Dim myChart As chart
Dim gChartData As ChartData
Dim gWorkBook As Excel.Workbook
Dim gWorkSheet As Excel.Worksheet
'Create the chart and set a reference to the chart data.
Set myChart = ActivePresentation.Slides(2).Shapes.AddChart.chart
Set gChartData = myChart.ChartData
'Set the Workbook and Worksheet references.
Set gWorkBook = gChartData.Workbook
Set gWorkSheet = gWorkBook.Worksheets(1)
With myChart
.ChartType = xlColumnStacked
.ChartStyle = 30
.ApplyLayout 4
.ClearToMatchStyle
End With
With myChart
.PlotArea.Left = 290
.PlotArea.Top = 90
End With
,收到以下的错误代码:
错误:运行期间-2147467259(80004005):
对象PlotArea的方法左失败
一些网站的搜索已经建议我可能有一个宏观的安全问题,但在选择所有宏操作都CUR肯定允许。
如果您需要更多信息,请让我知道。
谢谢!这对我有用 – Onno