代码如下:
失败的创建 -> ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="图表名称"
成功的创建 -> ActiveChart.Location xlLocationAsNewSheet
失败的创建 -> ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="图表名称"
成功的创建 -> ActiveChart.Location xlLocationAsNewSheet
Dim x As Chart
' Create an embedded chart on a chart sheet.
Set x = Charts.Add
x.ChartType = xlColumnClustered
x.SetSourceData Source:=Sheets("Sheet1").Range("A1:C4")
Set x = x.Location(where:=xlLocationAsObject, Name:="Sheet1")
' Move chart to new sheet and reset the chart object variable x.
Set x = x.Location(where:=xlLocationAsNewSheet, Name:="Chart1") ' Move chart to back to the chart sheet.
Set x= x.Location(where:=xlLocationAsObject, Name:="Sheet1")
End Sub