excel - 将图表导出到 PowerPoint 的代码运行时错误 91
问题描述
我正在尝试将图表从 Excel 导出到 PowerPoint,但在执行时它显示错误 91 说“对象变量或未设置块变量”
我已经做了研究,没有找到任何可以帮助我的东西。这是代码。
Sub ExportChartstoPowerPoint()
Dim PPApp As Object
Dim chr
Set PPApp = CreateObject("PowerPoint.Application")
PPApp.Presentations.Add
PPApp.ActiveWindow.ViewType = ppViewSlide
For Each chr In Sheets("CPIT Overview").ChartObjects
PPApp.ActivePresentation.Slides.Add PPApp.ActivePresentation.Slides.Count + 1, ppLayoutBlank
PPApp.ActiveWindow.View.GotoSlide PPApp.ActivePresentation.Slides.Count
chr.Select
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
PPApp.ActiveWindow.View.Paste
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
Next chr
PPApp.Visible = True
End Sub
错误在行ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
解决方案
推荐阅读
- java - 从 TableView 和 UpdateItem 覆盖方法中获取行
- javascript - 如何仅在项目加载时显示模式弹出窗口一次,而不是在页面上以 2/4 角度刷新
- javascript - javascript如何从li列表中的div获取文本
- single-sign-on - 登录后如何在 cas 服务器上设置额外的会话 cookie
- c - C中的Malloc 2D金字塔数组
- visual-studio-2017 - VS2017 v15.7.1 - 构建 | 发布创建不同的程序集来构建 | 重建解决方案
- css - 是否可以在输入中包含一个元素?
- c# - 使用不同的用户控件重用 Window 是否会破坏 MVVM 模式
- model - 在 spacy 中,如何使用自己在 gensim 中创建的 word2vec 模型?
- wordpress - WordPress :: add_action 插件简码