Powerpoint Application - Create Popup menu using VBA
The following code is a simple one to create popup menu in Powerpoint using VBA
Sub Add_Ctrl_To_Popup(ByVal sControlName As String, ByVal sMacroName As String)
On Error GoTo DisplayErr
' ---------------------------------------------------------------'
Written By Shasur for http://vbadud.blogspot.com
'---------------------------------------------------------------
Dim ctlCB As CommandBarDim ctlCommand As CommandBarControl
Set ctlCB = Application.CommandBars("Shapes")
If ctlCB Is Nothing Then Exit Sub
Set ctlCommand = ctlCB.Controls.Add
ctlCommand.Caption = sControlName
ctlCommand.OnAction = sMacroName
DisplayErr:
If Err <> 0 Then
MsgBox Err.Description
Err.Clear
Resume Next
End If
End Sub
Following sub will call the function
Sub Drive_Add_Ctrl_To_Poppup()
Add_Ctrl_To_Poppup "NewMenu", "Test"
End Sub
The above function will add an item to popup menu using VBA and assign a macro to it
See also:
Creating Menu’s and CommandBars in Powerpoint using VBA
Disable Cut & Copy from Popup menu (Excel VBA/Word VBA)
enable popup menu
Disable Right Click using VBA
Add Control To PopupMenu
Showing posts with label OnAction Property. Show all posts
Showing posts with label OnAction Property. Show all posts
Wednesday, September 17, 2008
Friday, May 04, 2007
Run Macro on Image Click
Tag Macro to an Image
Sub Run_Macro_On_ImageClick()
Dim sht As Worksheet
Dim shp As Shape
' Use OnAction Property to set the macro that needs to be run when the image is clicked
Set sht = ActiveSheet
Set shp = sht.Shapes(1)
shp.OnAction = "Macro1"
End Sub
Sub Run_Macro_On_ImageClick()
Dim sht As Worksheet
Dim shp As Shape
' Use OnAction Property to set the macro that needs to be run when the image is clicked
Set sht = ActiveSheet
Set shp = sht.Shapes(1)
shp.OnAction = "Macro1"
End Sub
Subscribe to:
Posts (Atom)
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.