M
Mel
PPT 2003/2007
I'm trying to understand arrays. I just want to capture the slides
currently selected and then running some actions on each of them,
which causes the selection to be lost, so I have to capture the slide
numbers before the action loop.
Likewise, I'm trying to do the same with selected shapes on a slide,
where I want to run a loop for each selected shape, but in doing so I
loose the selection so I need to first capture the selected shapes
names (I guess) and then run on all of them.
I've read and tried several things but it escapes me. Can someone show
me how this is done? Here's a feeble attempt I made...
Sub TestArray()
Dim iSldSelCnt As Integer
iSldSelCnt = ActiveWindow.Selection.SlideRange.Count
Dim iSldSelNum() As Integer
ReDim iSldSelNum(iSldSelCnt - 1) As Integer
Dim iSld As Long
iSld = 0
Dim oSld As Slide
For Each oSld In ActiveWindow.Selection.SlideRange
iSldSelNum(iSld) = oSld.SlideNumber
iSld = iSld + 1
Next oSld
ActivePresentation.Slides(iSldSelNum).Shapes.AddShape _
Type:=msoShapeRectangle, _
Left:=50, Top:=50, Width:=100, Height:=200
'ActiveWindow.Selection.SlideRange(iSldSelNum).Shapes.AddShape _
' Type:=msoShapeRectangle, _
' Left:=50, Top:=50, Width:=100, Height:=200
End Sub
Thanks,
-Melina
I'm trying to understand arrays. I just want to capture the slides
currently selected and then running some actions on each of them,
which causes the selection to be lost, so I have to capture the slide
numbers before the action loop.
Likewise, I'm trying to do the same with selected shapes on a slide,
where I want to run a loop for each selected shape, but in doing so I
loose the selection so I need to first capture the selected shapes
names (I guess) and then run on all of them.
I've read and tried several things but it escapes me. Can someone show
me how this is done? Here's a feeble attempt I made...
Sub TestArray()
Dim iSldSelCnt As Integer
iSldSelCnt = ActiveWindow.Selection.SlideRange.Count
Dim iSldSelNum() As Integer
ReDim iSldSelNum(iSldSelCnt - 1) As Integer
Dim iSld As Long
iSld = 0
Dim oSld As Slide
For Each oSld In ActiveWindow.Selection.SlideRange
iSldSelNum(iSld) = oSld.SlideNumber
iSld = iSld + 1
Next oSld
ActivePresentation.Slides(iSldSelNum).Shapes.AddShape _
Type:=msoShapeRectangle, _
Left:=50, Top:=50, Width:=100, Height:=200
'ActiveWindow.Selection.SlideRange(iSldSelNum).Shapes.AddShape _
' Type:=msoShapeRectangle, _
' Left:=50, Top:=50, Width:=100, Height:=200
End Sub
Thanks,
-Melina