jwalkerday
New Member
- Joined
- May 1, 2018
- Messages
- 18
Hello,
The following is attempting to iterate an array (2D String array) and use the values in order to create new powerpoint slides-
The array is populated correctly and all of the settings work.
The problem is the rng object (range) which uses a named range from the array is supposed to copy the range to the rng object.
It copies the first range in the array but not the subsequent ones in the loop even though the loop is working correctly and it works for all the other settings.
So I end up with multiple copies of the first named range as new slides.
It's like the rng object can only be set once and not get reused. Initially I thought that adding Set rng = Nothing would clear the object reference but that did not resolve the issue.
Is there something extra you need to do in order to reuse a range object in the way I am attempting (in combination with a named range from the spreadsheet)
Thanks,
walker
The following is attempting to iterate an array (2D String array) and use the values in order to create new powerpoint slides-
Code:
Dim rng as range
Dim loopI As Integer
For loopI = 0 To arrayLength - 1 'array starts at 0 so 1
'Add a slide to the Presentation
Set ppSlide = ppPresentation.Slides.Add(slideDataArray(loopI, 1), slideDataArray(loopI, 2)) 'slide number and slide setting (blank, title etc)
'Copy Range from Excel
Set rng = ActiveWorkbook.Sheets("BD Dashboard").range(slideDataArray(loopI, 0)) '0 is excel named range
'Copy Excel Range
rng.Copy
'Paste to PowerPoint and position
ppSlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
Set ppShape = ppSlide.Shapes(ppSlide.Shapes.Count)
'Clear The rng object
Set rng = Nothing
'scale
ppShape.Height = slideDataArray(loopI, 3)
ppShape.Width = slideDataArray(loopI, 4)
'Set position:
ppShape.Left = slideDataArray(loopI, 5)
ppShape.Top = slideDataArray(loopI, 6)
Next
The array is populated correctly and all of the settings work.
The problem is the rng object (range) which uses a named range from the array is supposed to copy the range to the rng object.
It copies the first range in the array but not the subsequent ones in the loop even though the loop is working correctly and it works for all the other settings.
So I end up with multiple copies of the first named range as new slides.
It's like the rng object can only be set once and not get reused. Initially I thought that adding Set rng = Nothing would clear the object reference but that did not resolve the issue.
Is there something extra you need to do in order to reuse a range object in the way I am attempting (in combination with a named range from the spreadsheet)
Thanks,
walker