Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

## Bing

Sure, here is a simple VBA code snippet that creates a PowerPoint presentation from
Excel data. This code assumes that you have data in column A that goes into one
text box, and the rest of the data goes into another text box.

Sub CreatePPTfromExcel()

' Create a new PowerPoint Application object


Dim pptApp As Object
Set pptApp = CreateObject("PowerPoint.Application")

' Create a new Presentation in the PowerPoint application


Dim pptPres As Object
Set pptPres = pptApp.Presentations.Add

' Loop through each row in the Excel worksheet


Dim i As Long
For i = 1 To ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row

' Add a new slide to the Presentation


Dim pptSlide As Object
Set pptSlide = pptPres.Slides.Add(i, 12) ' 12 = ppLayoutText

' Add data from Column A to the first text box


pptSlide.Shapes(1).TextFrame.TextRange.Text =
ThisWorkbook.Sheets("Sheet1").Cells(i, 1).Value

' Add data from the rest of the columns to the second text box
Dim j As Long
For j = 2 To ThisWorkbook.Sheets("Sheet1").Cells(i,
Columns.Count).End(xlToLeft).Column
pptSlide.Shapes(2).TextFrame.TextRange.Text =
pptSlide.Shapes(2).TextFrame.TextRange.Text & vbNewLine &
ThisWorkbook.Sheets("Sheet1").Cells(i, j).Value
Next j

Next i

' Make the PowerPoint application visible


pptApp.Visible = True

End Sub

Please replace "Sheet1" with your actual sheet name. This code assumes that your
PowerPoint layout has two text boxes. If your layout is different, you may need to
adjust the indices of pptSlide.Shapes accordingly. Also, please remember to save
your work before running this code as VBA can't be undone.

You might also like