Conver Chart to Image PowerPoint

时间:2017-06-15 11:16:13

标签: vba image charts powerpoint

我正在使用此处找到的解决方案(Converting PowerPoint charts to images)将powerpoint中的图表转换为图片。

解决方案完美无缺,但是当转换发生时,我希望图片“保持”与原始图表相同的位置和尺寸。

这可能吗?

1 个答案:

答案 0 :(得分:0)

实际上解决方案非常简单。必须记住形状的高度和宽度。

 Copy the shape the clipboard, delete it and then paste it back as a vector image
Private Function ReplaceChart(oSld As Slide, oShp As Shape)
  Dim shpTop As Single
  Dim shpleft As Single
  Dim shpWidth As Single
  Dim shpHeight As Single


  ' Save the chart position
  shpTop = oShp.Top
  shpleft = oShp.Left
  shpWidth = oShp.Width
  shpHeight = oShp.Height

  ' Copy, delete and paste the shape back as a picture
  oShp.Copy
  oShp.Delete
  ActiveWindow.View.PasteSpecial ppPasteEnhancedMetafile

  ' Get a reference to the new picture which will be the last shape in the shapes collection
  Set oShp = oSld.Shapes(oSld.Shapes.Count)

  ' Restore the chart picture position
  oShp.Top = shpTop
  oShp.Left = shpleft
  oShp.Width = shpWidth
  oShp.Height = shpHeight