Creating a Powerpoint Based on Excel Data

mrtim2232

New Member
Joined
Aug 24, 2017
Messages
48
Hi All,

I'm after a macro that will loop through all the rows in column A on an excel spreadsheet and create a powerpoint slide for each one and put the value from the cell on the slide and insert an image according to a specified filepath in column B. E.g. Create a slide tittle "Apple" from column a and then the image "C:\Pictures\Apple[image].png"

Any help would be appreciated.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Thankyou for your help I got this far:
Sub CreateSlides()
'Define the folder that contains all of the images. Make sure to include a trailing slash (\)
Dim ImageFolder As String
ImageFolder = "C:\Users\Pictures"

'Open the Excel workbook. Change the filename here.
'on 1st run goto tools> references> Microsoft excel 15.0 object library and make sure its ticked
Dim OWB As New Excel.Workbook
'Define the filepath and file type .xlsm / .xlsx
Set OWB = Excel.Application.Workbooks.Open("C:\Users\Downloads\REPORT.xlsx")

'Grab the first Worksheet in the Workbook change the number in brackets to the right number of sheet
Dim WS As Excel.Worksheet
Set WS = OWB.Worksheets(2)

'Loop through each used row in Column A
'change the i= value to tell it to start on a different row
For i = 2 To WS.Range("A65536").End(xlUp).Row
'Copy the first slide and paste at the end of the presentation
ActivePresentation.Slides(2).Copy
ActivePresentation.Slides.Paste (ActivePresentation.Slides.Count + 1)

'Change the text of the first text box on the slide.
ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes(1).TextFrame.TextRange.Text = WS.Cells(i, 1).Value

'Set the image location of the shape

ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes(2).Fill.UserPicture (ImageFolder + WS.Cells(i, 2).Value)
Next
End Sub

However it keeps faulting out on the fill.userpicture line with the following message:
Method 'userpicture' of object 'fillformat' failed

If you have any suggestions it would be appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
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