【问题标题】:Paste Special excel to powerpoint keeps giving 424 object required error when trying to resize尝试调整大小时,将特殊 excel 粘贴到 powerpoint 不断给出 424 object required 错误
【发布时间】:2014-11-26 19:09:54
【问题描述】:

所以我一直在尝试调整从 excel 开始并使用特殊粘贴方法粘贴到 PPT 幻灯片的链接图表的大小。不幸的是,无论我在尝试调用设置高度/宽度/等的方法时做什么,我都会一直遇到“需要 424 个对象”错误...我从另一个 SO 帖子复制/粘贴了这个确切的代码,错误仍然存​​在,特别是在 .height = 200 行

Sub CopyDataToPPT()

    Dim objslide
    Dim objRange As Range
    Dim objPPT As PowerPoint.Application
    Dim objPresentation As Presentation
    Dim shapePPTOne As Object


    Set objPPT = CreateObject("PowerPoint.Application")
    Set objPresentation = objPPT.Presentations.Add

    Set objslide = objPresentation.Slides.Add(1, ppLayoutTitleOnly) 'you had inLayout???
    objslide.Shapes.Title.TextFrame.TextRange.Text = "blah blah"

    Sheets("Sheet1").Range("C6:G22").Copy
    DoEvents

    Set shapePPTOne = objslide.Shapes.PasteSpecial( _
                DataType:=ppPasteEnhancedMetafile, Link:=msoFalse)

    With shapePPTOne
        .Height = 200
        .Left = 50
        .Top = 100
    End With

    Application.CutCopyMode = False

End Sub

Excel/PPT/VBA 参考资料均已到位,并且已经过彻底检查,我已尝试切换顺序/优先级。该错误发生在多台运行 excel/PPT 2013 的不同计算机上。我尝试了此代码的多种变体,但不断遇到错误,这让我相信它可能不是实际代码本身。我还读到,在 excel 中调整列/行通常更容易,但在我的情况下,我需要以非常具体的方式将图表发布在 powerpoint 幻灯片上。任何人可以提供的帮助将不胜感激!

*EDIT - 还想指出粘贴和调整高度/宽度/等..仅使用简单粘贴方法时效果很好

【问题讨论】:

    标签: vba excel powerpoint


    【解决方案1】:

    想通了...解决方案很简单。Height = 200 应该是 shapePPTOne(1).Height = 200

    【讨论】:

    • 或更一般地说,设置 shapePPTOne = objslide.Shapes.PasteSpecial( _ DataType:=ppPasteEnhancedMetafile, Link:=msoFalse)(1) 因为粘贴返回一个 shaperange(可能包含 1 个或多个形状)和在这种情况下,你知道你想要第一个,所以继续 (1)
    猜你喜欢
    • 1970-01-01
    • 2017-11-28
    • 2020-12-21
    • 1970-01-01
    • 1970-01-01
    • 2019-04-13
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    相关资源
    最近更新 更多