VBA Copy 4 rows from Excel and Paste into PowerPoint with Custom Layout

jackson1990

Board Regular
Joined
Feb 21, 2017
Messages
56
Hello everyone,

I'm very close to completing something I want to do, but I'm not quite understanding the last puzzle piece. My code is below:

VBA Code:
Sub CopyCellAsTextBoxTextToPPTSlide()
'requires a reference to Microsoft PowerPoint
'In VBE: tools, references, check Microsoft PowerPoint X.0 Object Library

    Dim oPPT As PowerPoint.Application
    Dim oPres As Presentation
    Dim oSld As Slide
    Dim LR As Long, LC As Long

    Set oPPT = CreateObject("PowerPoint.Application")
    oPPT.Visible = True
    Set oPres = oPPT.Presentations.Add

    With ActiveSheet
        LR = .Cells(.Rows.Count, 1).End(xlUp).Row
        LC = .Cells(1, .Columns.Count).End(xlToLeft).Column
        For i = 1 To LR
            Set oSld = oPres.Slides.Add(i, ppBlank)
            For j = 1 To LC
                oSld.Shapes.AddTextbox msoTextOrientationHorizontal, 15, 50 * j + 5, 500, 10 'adjust numbers here to suit
                oSld.Shapes(j).TextFrame.TextRange.Text = .Cells(i, j).Value
            Next
        Next
    End With
End Sub

So as you can see I am having excel create a slide for each row for the first four columns. It spits that out perfectly to a blank template. BUT I have created a custom template with a custom layout slide I want it to use (it is laid out better for the presentation of text). It is called PotP (the custom layout and template are both named this). I'm having trouble understanding (and I looked at various forums and threads to try to understand) how to get it to use a custom template/layout instead of just spitting it into the blank one.

Any help here?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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