excel - 宏从 Excel 向 PowerPoint 发送请求:代码在我的计算机上工作,而不是在用户的计算机上
问题描述
我的代码从 Excel 调用 PowerPoint 并使用电子表格中的数据创建幻灯片。该代码适用于我的计算机,但用户收到错误 1004。
我曾尝试使用其他人以前开发的另一个代码。这个:https ://www.thespreadsheetguru.com/blog/2014/3/17/copy-paste-an-excel-range-into-powerpoint-with-vba
由于某些原因,此代码再次适用于我的计算机,但不适用于用户的计算机。它会在某些选项卡上导致系统错误 400,但它适用于 1 个选项卡。
Sub CopyRangeToPresentationTot()
'Step 1: Declare your variables
Dim PP As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim SlideTitle As String
'Step 2: Open PowerPoint and create new presentation
Set PP = New PowerPoint.Application
Set PPPres = PP.Presentations.Add
PP.Visible = True
'Step 3: Add new slide as slide 1 and set focus to it
Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)
PPSlide.Select
'Step 4: Copy the range as a picture
Sheets(ActiveSheet.Name).Range("B2:F18").CopyPicture _
Appearance:=xlScreen, Format:=xlPicture
'Step 5: Paste the picture and adjust its position
PPSlide.Shapes.Paste.Select
PP.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PP.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
'Step 7: Memory Cleanup
PP.Activate
Set PPSlide = Nothing
Set PPPres = Nothing
Set PP = Nothing
End Sub
我希望我的代码将创建一张幻灯片,其中包含 Excel 中的范围作为图片。用户遇到 1004 错误。
解决方案
推荐阅读
- c# - 我可以使用 = 运算符指定构造函数值吗?
- neo4j - 通过提交将更新操作拆分为块
- .net - 如何在 Server Core 上安装 .NET Framework 升级?
- r - 如何更改 hc_xAxis 中的时间范围 - 以季度为单位的月份
- javascript - CasperJS 的示例代码不起作用
- c# - 如何将 webhook 与 paypal 退货请求集成
- java - 双链表的第一个和最后一个元素
- javascript - 使用蒙特卡罗模拟计算 pi
- java - 从 REST 控制器返回的 InputStreamResource 中未释放的 InputStream
- swift - appcode 找不到 cocoapods 安装的类