New in VBA for ppt. (used to do more Excel vba). Below macro is really simple and works fine in normal mode , when I run it in PowerPoint's VBA editor. (Will add a blue rectangle shape in the center of the screen)
To work in slide show, I assigned the macro to a random shape through the action setting option but nothing happen really. Thanks
Sub Rdmrectangle()
Dim sld As Slide
Dim shp As Shape
Dim SlideIndex As Long
SlideIndex = ActiveWindow.View.Slide.SlideIndex
Set sld = ActivePresentation.Slides(SlideIndex)
Set shp = sld.Shapes.AddShape(Type:=msoShapeRectangle, _
Left:=50, Top:=50, Width:=100, Height:=200)
With ActivePresentation.PageSetup
shp.Left = (.SlideWidth \ 2) - (shp.Width \ 2)
shp.Top = (.SlideHeight \ 2) - (shp.Height \ 2)
End With
shp.Fill.ForeColor.RGB = vbBlue
shp.ZOrder msoBringToFront
End Sub