我想在Access编程创建图表PowerPoint演示。理想的情况是,当图表移动到PowerPoint中,他们将成为静态的图片和图表不是仍然连接到访问数据。

我曾尝试程序,例如:

 Private Sub Command1_click()
     Dim pwrpnt as Object
     Dim Presentation as Object

     set pwrpnt = CreateObject("Powerpoint.Application")
     pwrpnt.Activate
     Set Presentation = pwrpnt.Presentation.Open("C:\test.ppt")
     Me.Graph1.SetFocus
     Runcommand acCmdcopy

     Presentation.Slides(1).Shapes.Paste
     set pwrpnt = Nothing
     set Presentation = Nothing
End Sub

和我得到一个错误消息,如:粘贴方法失败

有没有更好的方法吗?并且可以将它被迫成为静态图像?

感谢您。

有帮助吗?

解决方案

好,我发现了一种方法做到这一点。我如果任何人有一个更优雅的方式仍然有兴趣,但对于其他人处理类似的问题:

Private Sub Command1_click()
 'Note: Sample only, in real code this should probably have something to save the 
 'PPT file and then close the powerpoint application, not to mention some error handling,
 ' and possibly some picture formatting, etc.  

 Dim pwrpnt as PowerPoint.Application
 Dim Presntation as PowerPoint.Presentation

 Me.Graph0.Action = acOLECopy
 set pwrpnt = CreateObject("Powerpoint.Application")
 pwrpnt.Activate
 Set Presentation = pwrpnt.Presentations.Open("TemplateFile.ppt")
 pwrpnt.ActiveWindow.ViewType = ppViewSlide

 'This inserts it as a picture, just use .Paste to insert it as an actual chart.
 pwrpnt.ActiveWindow.View.PasteSpecial ppPasteEnhancedMetafile 
EndSub

其他提示

是的,这正是我使用的技术 - 我花了几天寻找解决方案的网络。它不是很优雅,但它的工作原理和好处是,你在简报的MS图形对象,以便用户可以方便地运用自己的造型,模板等

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top