【发布时间】:2013-03-22 04:01:03
【问题描述】:
我可以从 Powerpoint 将图表导出为 JPG 文件,但无法使用表格执行此操作,据我所知,表格仍然是应该能够导出的“形状”。
这是我用来将图表导出为 JPG 的代码的清理版本。
Const imgFilePath as String = "ChartImage.JPG"
Sub ExportChartJPG()
Dim cht as Variant 'this will hold the Chart/Shape object
Set cht = ActivePresentation.Slides(1).Shapes("Chart1").Chart
On Error Resume Next
Kill imgPath
On Error GoTo 0
cht.Export imgPath, "JPG"
End Sub
我认为这很容易修改,例如:
Sub ExportChartJPG()
Dim cht as Variant 'this will hold the Chart/Shape object
Set cht = ActivePresentation.Slides(1).Shapes("Table1").Table
On Error Resume Next
Kill imgPath
On Error GoTo 0
cht.Export imgPath, "JPG"
End Sub
但这会引发错误13 Mismatch。
我还尝试将cht 标注为形状而不是变体,并将cht = ActivePresentation.Slides(1).Shapes("Table1") 设置为也未成功。
【问题讨论】:
标签: vba powerpoint