问题
I have written a macro that exports from excel to powerpoint and have gotten it to work properly in 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.
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.
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
回答1:
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. Here is a good primer on the differences between early and late binding.
来源:https://stackoverflow.com/questions/23140346/how-to-resolve-missing-powerpoint-15-object-library-error