[英]Copy and paste graph of one PowerPoint presentation to another PowerPoint presentation with inputbox
Hello:) what I want to do is to have a Master document (PowerPoint) to use as template and personalize with graphics that are in another PowerPoint presentation.你好:) 我想做的是有一个主文档 (PowerPoint) 用作模板并使用另一个 PowerPoint 演示文稿中的图形进行个性化。 The master document on the code is "pre".代码上的主文档是“pre”。 The PowerPoint with the graphics is "graphs_pre".带有图形的 PowerPoint 是“graphs_pre”。 The idea is to click in a image on a slide of "pre" and a input box appears asking "Please enter the name of the graph", we write the name of the graph, the code opens the "graphs_pre" search for the graph with the same name and copy and paste on the "pre".思路是在“pre”的幻灯片上点击图片,出现一个输入框询问“请输入图的名称”,我们写下图的名称,代码打开“graphs_pre”搜索图具有相同的名称并复制并粘贴在“pre”上。 This isn't working, always giving a lot of errors.这不起作用,总是给出很多错误。 So I need your help please.所以我需要你的帮助。 Please bare in mind that I have zero experience in coding...请记住,我在编码方面的经验为零......
Code:代码:
Sub test()
Dim vSlide As Slide
Dim vSlide As Slides
Dim vShape As Shape
Dim vShapes As Shapes
Dim pre As Presentation
Dim graphs_pre As Presentation
Set pre = ActivePresentation
Set graphs_pre = Presentations.Open ("path of the graph presentation", msoFalse)
strResult = InputBox ("Please enter the name of the graph")
Set vShapes = Presentations(Dir("path of graph presentation").Slides.Shapes
For each vShape in vShapes
If strResult = vShape.Name Then
vShape.Copy
pre.Slides.Paste
End If
Next vShape
End Sub
Let's see if this (air code) gets you a little closer:让我们看看这个(空气代码)是否能让你更接近一点:
Sub test()
Dim vSlide As Slide
'Dim vSlide As Slides
Dim vSlides as Slides
Dim vShape As Shape
Dim vShapes As Shapes
Dim pre As Presentation
Dim graphs_pre As Presentation
' You use this later w/o DIMming it so add this
Dim strResult as String
Set pre = ActivePresentation
Set graphs_pre = Presentations.Open ("path of the graph presentation", msoFalse)
strResult = InputBox ("Please enter the name of the graph")
' I don't understand what this is supposed to do
' Set vShapes = Presentations(Dir("path of graph presentation").Slides.Shapes
' but I THINK you need to do this:
For each vSlide in graphs_pre.Slides
For each vShape in vSlide.Shapes
If strResult = vShape.Name Then
vShape.Copy
' This will paste onto the first slide in pre for now
' Which slide do you really WANT it on?
pre.Slides(1)Shapes.Paste
End If
Next ' vShape
Next ' vSlide
End Sub
And once you're all done, you'll want to do graphs_pre.Close一旦你完成了,你会想要做 graphs_pre.Close
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.