You can add button in every slide whenever you add a new slide as below:
First open VBA editor and add Class Modules and Copy & Paste below code. This is a class module and contains event of powerpoint. It contains Newslideadd event which trigger always whenever a new slide will be added and create a shape in top right corner and assign a macro to the shape.
Now add a module and add below code, save file and reopen it as auto open need to run to assigining event to powerpoint application otherwise NewSlideAdd event will not trigger.Code:Option Explicit Public WithEvents PPTEvent As Application Private Sub PPTEvent_PresentationNewSlide(ByVal Sld As Slide) Dim shpAddNew As Shape Dim dblWidth As Double dblWidth = ActivePresentation.PageSetup.SlideWidth Set shpAddNew = Sld.Shapes.AddShape(msoShapeRectangle, dblWidth - 100, 10, 80, 20) With shpAddNew .TextEffect.Text = "Click Me" .TextEffect.FontSize = 12 .ShapeStyle = 35 With .ActionSettings(ppMouseClick) .Run = "SayHello" .Action = ppActionRunMacro End With End With shpAddNew.ActionSettings(ppMouseClick).Action = ppActionRunMacro End Sub
Code:Option Explicit Public cPPTObject As New cNewSlideClass Sub Auto_Open() 'set a application reference to the event-enabled object Set cPPTObject.PPTEvent = Application End Sub Sub SayHello() MsgBox "Hello World" End Sub




Reply With Quote
Bookmarks