Help Converting This From Early Binding To Late Binding

CaliKidd

Board Regular
Joined
Feb 16, 2011
Messages
173
I am using Excel 2007 to create a Powerpoint presentation via early binding. I would like to convert the code to late binding since I want people to be able to use other versions of Office (e.g., 2010).

Can someone tell me what changes are needed to accomplish this?

Here's a snippet of my code:
Code:
Private Sub Build_Powerpoint_Presentation_Button_Click()
    Dim PPApp As PowerPoint.Application
    Dim PPPres As PowerPoint.Presentation
    Dim PPSlide As PowerPoint.Slide
    Dim Path As String
    Dim Slide_Number as Byte
 
    Path = ThisWorkbook.Path
    On Error Resume Next
    Set PPApp = GetObject(, "Powerpoint.Application")
    If PPApp Is Nothing Then 'Could not get instance, so create a new one
        Set PPApp = CreateObject("Powerpoint.Application")
        PPApp.Visible = True
        Slide_Number = 1
        Set PPPres = PPApp.Presentations.Open(Path & "\Presentation Template.potx")
        With PPApp.ActivePresentation.Slides(Slide_Number)
            .shapes(1).TextFrame.TextRange.Text = "Inventory Report"
            .shapes(2).TextFrame.TextRange.Text = "July 2011"
        End With
        Slide_Number = Slide_Number + 1
        With PPApp.ActivePresentation.Slides.Add(Slide_Number, ppLayoutText)
            .shapes(1).TextFrame.TextRange.Font.Size = 28
            .shapes(1).TextFrame.TextRange.Text = "Location Information:"
            .shapes(1).TextFrame.AutoSize = ppAutoSizeShapeToFitText
            .shapes(1).Top = 50
            .shapes(2).TextFrame.TextRange.Font.Size = 14
            .shapes(2).TextFrame.TextRange.Text = Location_Information_Bullets
            .shapes(2).Top = 85
            .shapes(2).Height = 400
            .shapes(2).TextFrame.AutoSize = ppAutoSizeShapeToFitText
        End With
    End If
    MsgBox ("Your presentation has been generated in the background.  Please switch over to Microsoft PowerPoint to view the presentation."), vbOKOnly + vbInformation, "Report Complete:"
    Set PPSlide = Nothing
    Set PPPres = Nothing
    Set PPApp = Nothing
End Sub
When I change the first three lines to:
Code:
    Dim PPApp As Object
    Dim PPPres As Object
    Dim PPSlide As Object
I get an error message on this line, stating that the "ppLayoutText" variable is not defined.
Code:
        With PPApp.ActivePresentation.Slides.Add(Slide_Number, ppLayoutText)

Can someone tell me the enumeration value for ppLayoutText (as well as the other early binding layout types)?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Can someone tell me the enumeration value for ppLayoutText (as well as the other early binding layout types)?
It's 2. To discover the other values, add/reinstate the reference to the Powerpoint Object Library, open the Object Browser in the VB editor (press F2) and search for pplayouttext.
 
Upvote 0
Another trick (not that it's a bad idea to become familiar with the object browser):

Type into the immediate window (in your powerpoint visual basic editor or with PP still referenced in your Excel project):
Code:
?ppLayoutText
 
Last edited:
Upvote 0
Hi all,

Another quick way (with the library referenced) is to click on the constant, right-click, and choose 'Quick Info'

Hope that helps,

Mark
 
Upvote 0
Thanks Alex:)... anything to save my fumbly fingers a few keystrokes:laugh:

Have a great weekend!
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,922
Latest member
nstaab07

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top