Hi All,
Am trying to load some excel data into already existing powerpoint file as images. These images need to be posted on specific slide numbers and this is where I'm having trouble with. I'm able to copy the data from excel and also make it paste to Powerpoint from Slide 1 but not able to paste it to specific slides. Below is the code:
Sub DeleteAllPictures()
Dim lngTemp As Long
Dim lngCount As Long
Dim PowerPointApp As PowerPoint.Application
Set PowerPointApp = New PowerPoint.Application
PowerPointApp.Visible = True
Dim rng As Excel.range
Dim myShapeRange As PowerPoint.ShapeRange
Dim mySlide As PowerPoint.Slide
Dim lRow As Long
Dim lol As Long
Dim arrSlides() As Variant
arrSlides = Array(1, 4, 6) ' Defining the array
Dim ab As Integer
Dim myPresentation As PowerPoint.PresentationSet myPresentation = PowerPointApp.Presentations.Open("XXXX\04.30.pptx")
For Each mySlide In myPresentation.Slides
For lngCount = mySlide.Shapes.Count To 1 Step -1
With mySlide.Shapes(lngCount)
If .Type = msoPicture Then
.Delete
End If
End With
Next
Next (Using this part of the code to delete pictures already existing on the powerpoint)
lCol = 23
lRow = 3
If lCol < 134 Then
Set rng = ThisWorkbook.ActiveSheet.range("B" & lRow & ":" & "P" & lCol)
rng.Copy
'' Below part is where I'm having issues. Here I'm trying to loop through the array & only when the condition of slide #1, 4, 6 matches then it should execute the "copy paste piece of code. However not able to do that.
For ab = LBound(arrSlides) To UBound(arrSlides) 'Each ab In arrSlides
''Set myslides = PowerPointApp.ActivePresentation.Slides(arrSlides)
''Set myShapeRange = ActivePresentation.Slides.Shapes.PasteSpecial(DataType:=ppPasteBitmap)
''Set mydocument = PowerPointApp.ActivePresentation.Slides
Set myShapeRange = arrSlides(ab).Shapes.PasteSpecial(DataType:=ppPasteBitmap)
myShapeRange.Left = 0.24 * 72
myShapeRange.Top = 1.43 * 72
myShapeRange.Height = 4.26 * 72
myShapeRange.Width = 9.2 * 72
CutCopyMode = False
lCol = lCol + 22
lRow = lRow + 22
Next ab
End If
'End With
End Sub
Other general question I have.
a) Is there a way to know the Slide ID of each slide? If yes, is there a way to do this without macros? Just by GUI?
Bookmarks