adding action to a shape in powerpoint through excel vba

LAWS

New Member
Joined
Dec 23, 2019
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
HI GUYS
am trying to add a shape in power point slide and add action (click event) to run a macro.

through power point vba, it worked perfectly and this is the code i used.

VBA Code:
Option Explicit
Sub ADDSHAPE()
Dim pppres As Presentation
Dim pslide As Slide
Dim pshp As Shape

Set pppres = ActivePresentation
Set pslide = pppres.Slides(1)

Set pshp = pslide.Shapes.ADDSHAPE(msoShapeRound1Rectangle, 800, 100, 100, 50)
pshp.TextFrame.TextRange.Text = "CLICK ME!"
With pshp.ActionSettings(ppMouseClick)
         .Action = ppActionRunMacro
         .Run = "ADDTEXTBOX"
         .AnimateAction = msoCTrue
End With
 
End Sub

and this is the macro am trying to call
VBA Code:
Sub ADDTEXTBOX()
Dim pppres As Presentation
Dim pslide As Slide
Dim shp As Shape

Set pppres = ActivePresentation
Set pslide = pppres.Slides(1)

Set shp = pslide.Shapes.ADDTEXTBOX(msoTextOrientationHorizontal, 100, 100, 100, 50)
shp.TextFrame.TextRange.Text = "i have done it!"

End Sub

BUT IF I USE EXCELL VBA,IT FAILS!!!

THIS IS THE EXCEL CODE I USED
VBA Code:
Option Explicit
Option Base 1
Sub powerointt_animations()
Application.ScreenUpdating = False
Dim ppapp As New PowerPoint.Application
Dim pppres As PowerPoint.Presentation
Dim shp As PowerPoint.Shape
Dim sld, pslide As PowerPoint.Slide


With ppapp
.Activate
.Visible = msoCTrue
.WindowState = ppWindowMaximized
End With



Set pppres = ppapp.Presentations.Add

Set pslide = pppres.Slides.Add(1, ppLayoutBlank)

pppres.Slides(1).SlideShowTransition.AdvanceOnClick = msoFalse

Set shp = pslide.Shapes.AddShape(msoShapeRound1Rectangle, 800, 100, 100, 50)

shp.TextFrame.TextRange.Text = "CLICK ME!"
With shp.ActionSettings(ppMouseClick)
         .Action = ppActionRunMacro
         .Run = "ADDTEXTBOX"
         .AnimateAction = msoCTrue
End With
 'pppres.SlideShowSettings.Run
Application.ScreenUpdating = True

End Sub

plus the modified macro in excel vba i intend to call

VBA Code:
Sub ADDTEXTBOX()
Dim pppres As PowerPoint.Presentation
Dim pslide As PowerPoint.Slide
Dim shp As PowerPoint.Shape

'add text
Set pppres = ActivePresentation

Set shp = pslide.Shapes.ADDTEXTBOX(msoTextOrientationHorizontal, 100, 100, 100, 50)

shp.TextFrame.TextRange.Font.Color.RGB = rgbWhite
shp.TextFrame.TextRange.Text = "THATS IS IT!"

End Sub

attached find a screen shots of the error
error1.PNG
error2.PNG



am wondering where i went wrong
kindly help. thanks!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Shouldn't the sub ADDTEXTBOX be in the PowerPoint presentation?
 
Upvote 0

Forum statistics

Threads
1,215,836
Messages
6,127,182
Members
449,368
Latest member
JayHo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top