如何在复制excel表格时使用“添加新幻灯片”;至于;从Excel vba循环?
问题1)错误是“对象不支持此道具或方法”,仅在如何在复制excel表格时使用“添加新幻灯片”;至于;从Excel vba循环?,excel,vba,powerpoint,Excel,Vba,Powerpoint,问题1)错误是“对象不支持此道具或方法”,仅在计数+1处。选择行。我犯了什么错 问题2)如果我在相同的幻灯片中有两个区域的单元格“A1:E9”和“A11:E20”,我想粘贴到相同的幻灯片中,是否有方法编写代码,从A1中查找非空单元格并将数据复制到最后一个填充行并粘贴到powerpoint中 为这个冗长的问题道歉。我很乐意得到任何答案 Set myPresentation=PowerPointApp.ActivePresentation.AddSlide(PowerPointApp.Slides.
计数+1处。选择行。我犯了什么错
问题2)如果我在相同的幻灯片中有两个区域的单元格“A1:E9”和“A11:E20”,我想粘贴到相同的幻灯片中,是否有方法编写代码,从A1中查找非空单元格并将数据复制到最后一个填充行并粘贴到powerpoint中
为这个冗长的问题道歉。我很乐意得到任何答案
Set myPresentation=PowerPointApp.ActivePresentation.AddSlide(PowerPointApp.Slides.Count+1,PowerPoint.PpSlideLayout.pplayout为空)。选择
这有两个问题:
您之前已经设置了myPresentation=PowerPointApp.ActivePresentation
。我想你指的是mySlide
PowerPointApp.ActivePresentation
-使用myPresentation
,这是多余的
方法不是Application.AddSlide
或Presentation.AddSlide
…但您需要幻灯片。添加
,因为添加幻灯片
将自定义布局
作为其第二个参数
PowerPointApp.Slides.Count
-应用程序没有Slides
属性;应该是myPresentation.Slides.Count
PowerPoint.PpSlideLayout.ppLayoutBlank
-请注意,此早期绑定,而其余代码使用后期绑定。(Dim myPresentation As Object
,Dim mySlide As Object
,等等)。最好保持一致。我已经制定了一个早期绑定方法
通过这些修订:
Dim myPresentation As Object
Dim mySlide As Object
Dim PowerPointApp As Object
Dim shp As Object
Dim MySlideArray As Variant
Dim MyRangeArray As Variant
Dim x As Long
PowerPointApp.ActiveWindow.Panes(1).Activate
Set myPresentation = PowerPointApp.ActivePresentation
MySlideArray = Array(1, 2)
MyRangeArray = Array(Worksheets("name").Range("A3:E17"), Worksheets("age").Range("A22:E37"))
For x = LBound(MySlideArray) To UBound(MySlideArray)
MyRangeArray(x).Copy
Set shp = myPresentation.Slides(MySlideArray(x)).Shapes.PasteSpecial(DataType:=2)
Set myPresentation = PowerPointApp.ActivePresentation.AddSlide(PowerPointApp.Slides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutBlank).Select
Next x
您已经设置了myPresentation=PowerPointApp.ActivePresentation
。。。为什么要再次尝试设置myPresentation=
<代码>设置mySlide=myPresentation.AddSlide(myPresentation.Slides.Count+1…@BigBen-我尝试了你的cmd,但错误仍然存在。mySlide
或myPresentation
都是具有属性addslide
的对象。我不知道运行时错误438的原因。对不起-我的错-应该是myPresentation.Slides.addslide>这句话有几个问题……写一个答案。太棒了!谢谢你。我羡慕你的知识!我犯了很多错误,尤其是在使用对象和方法时。如果有人能帮助我完成第2部分,我会等待,但我将你的标记为答案。@SatvikK-可能对问题2有所帮助,但我不确定我是否确切理解最终目标是什么……可能是问一个新问题更容易。我已经把我的问题贴在这里了。提前谢谢。
Const ppLayoutBlank as Long = 12
With myPresentation.Slides
Set mySlide = .Add(.Count + 1, ppLayoutBlank)
End With