1
votes

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
You'll need to either include definitions for the PowerPoint constants (ppLayoutTitleOnly) or simply use the actual values; ppLayoutTitleOnly = 11. ppPasteEnhancedMetafile = 2. Both are Longs. .Height should be a Single. VBA will convert for you but it's better to get it right in the first place.Steve Rindsberg
Steve it is still freezing at the line of code ObjPPT = createobject("Powerpoint.application")Note new error message: microsoft excel is waiting for another application to complete an OLE ActionEdward Armstrong
Have you tried restarting the computer? Sometimes PPT/Excel leave invisible copies of themselves behind (especially common when you're automating them from other apps). That can cause all sorts of problems. A restart gives you a clean slate.Steve Rindsberg
Thanks Steve its now working. Its always the simplest solution :) . Do you have any idea how to make .height .left work with the code? . Or coding this: objPresentation.SlideMaster.ApplyTheme "C:\Users\" & (Environ$("Username")) & "\AppData\Roaming\Microsoft\Templates\Document Themes\CMB.thmx"Edward Armstrong
@SteveRindsberg Any idea how to fix this? Is this an issue with object type?Edward Armstrong

1 Answers

1
votes

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.