vba 如何解决丢失的 Powerpoint 15 对象库错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23140346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 02:48:39  来源:igfitidea点击:

How to resolve Missing Powerpoint 15 Object Library Error

excelexcel-vbapowerpoint-vbalate-bindingvba

提问by Edward Armstrong

I have written a macro that exports from excel to powerpoint and have gotten it to work properly in Excel/Powerpoint 2013, 2010.

我编写了一个从 excel 导出到 powerpoint 的宏,并使其在 Excel/Powerpoint 2013、2010 中正常工作。

However I tested it on another version of Excel 2010 and got a VBA error that it was missing powerpoint object library 15. I tried running the macro with powerpoint library 14 and was able to but it wasn't reformatting the slides or doing a lot of the formatting that I was doing.

但是,我在另一个版本的 Excel 2010 上对其进行了测试,并得到了一个 VBA 错误,即它缺少 powerpoint 对象库 15。我尝试使用 powerpoint 库 14 运行宏并且能够运行,但它没有重新格式化幻灯片或做了很多我正在做的格式化。

What is the best way/easiest way to install an object library. Can I browse and import the file from the reference tab? If so how can I locate a dl file for the object library? I need to tell a client so i'm trying to make this as easy as possible.

安装对象库的最佳方式/最简单的方式是什么。我可以从参考选项卡浏览和导入文件吗?如果是这样,我怎样才能找到对象库的 dl 文件?我需要告诉客户,所以我试图让这一切尽可能简单。

Note My code is below. I am having a hard time changing this to early binding per adam's feedback below.

注意我的代码如下。根据下面亚当的反馈,我很难将其更改为早期绑定。

  Sub CopyDataToPPT()
'Const ppLayoutBlank = 12
Dim objWorkSheet As Worksheet
Dim objRange As Range
Dim objPPT As Object
Dim objPresentation As Object
Dim shapePPTOne As Object
Dim intLocation, intHeight, inLayout As Integer
Dim strRange As String
Dim boolOK As Boolean

Application.ScreenUpdating = False
'Set objWorkSheet = ThisWorkbook.ActiveSheet

Set objPPT = CreateObject("PowerPoint.Application")

objPPT.Visible = True
inLayout = 1

Set objPresentation = objPPT.Presentations.Add


    boolOK = False
        strRange = "p19:y48"  '<- here
        intHeight = 430
        boolOK = True

    If boolOK = True Then
        Set objslide = objPresentation.Slides.Add(1, inLayout)
        objPresentation.Slides(1).Layout = ppLayoutTitleOnly

        objPresentation.Slides(1).Shapes.Title.TextFrame.TextRange.Text = "Reebok- " & Sheets("Brand Personality").Cells(3, 2)

        Set objRange = Sheets("Brand Personality").Range(strRange)
        objRange.Copy

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


        shapePPTOne(1).Left = 220
        shapePPTOne(1).Top = 100
        shapePPTOne(1).Height = intHeight

        Application.CutCopyMode = False
    End If

采纳答案by Adach1979

The library can not be installed just by itself. The simpler way in this situation is to use late binding in your code which should remove the library dependency. Hereis a good primer on the differences between early and late binding.

该库不能单独安装。在这种情况下,更简单的方法是在您的代码中使用后期绑定,这应该删除库依赖项。是关于早期绑定和晚期绑定之间差异的很好的入门读物。