Hi, I am trying to export 3 columns of data from excel to Powerpoint. I am using the below code. My excel file opens but I receive a 424 error before anything is exported.
I have used this code before. Am I missing something? I use the code in a fresh excel spreadsheet and have a PPT open with 3 text boxes.
Any help would be appreciated!...
Sub CreateSlides()
'Open the Excel workbook. doc name.
Dim OWB As New Excel.Workbook
Set OWB = Excel.Application.Workbooks.Open("C:doc location.xlsx")
'Grab the first Worksheet in the Workbook
Dim WS As Excel.Worksheet
Set WS = OWB.Worksheets(1)
'Loop through each used row in Column A
For i = 1 To WS.Range("A65536").End(xlUp).Row
'Copy the first slide and paste at the end of the presentation
ActivePresentation.Slides(1).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
ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes(2).TextFrame.TextRange.Text = WS.Cells(i, 2).Value
ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes(3).TextFrame.TextRange.Text = WS.Cells(i, 3).Value
Next
End Sub
Bookmarks