【问题标题】:Creating a Powerpoint with Graphs from Access使用 Access 中的图表创建 Powerpoint
【发布时间】:2010-11-05 15:48:00
【问题描述】:

我正在尝试以编程方式从 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

我收到一条错误消息,例如:粘贴方法失败。

有没有更好的方法?并且可以强制变成静态图片吗?

谢谢。

【问题讨论】:

    标签: ms-access vba graph powerpoint


    【解决方案1】:

    好的,我找到了办法。如果有人有更优雅的方式,我仍然感兴趣,但对于其他处理类似问题的人:

    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
    

    【讨论】:

      【解决方案2】:

      是的,这正是我使用的技术 - 我花了几天时间在网上搜索解决方案。它不是很优雅,但很有效,而且好处是您在 Powerpoint 中获得了一个 MS Graph 对象,以便用户可以轻松应用自己的样式、模板等

      【讨论】:

        猜你喜欢
        • 2010-10-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多