Reputation: 1
I am trying to create pop-up menu, that will give option to copy-paste a shape object out from shape group named "Element" (Oval + Text Box). But it seemed that Select & Paste methods did not work.
Public Element_Menu As CommandBar
Function CreateSubMenu() As CommandBar
Const pop_up_name = "pop-up menu"
Dim the_command_bar As CommandBar
Dim the_command_bar_control As CommandBarControl
For Each menu_item In CommandBars
If menu_item.Name = pop_up_name Then
CommandBars(pop_up_name).Delete
End If
Next
Set the_command_bar = CommandBars.Add(Name:=pop_up_name, Position:=msoBarPopup, MenuBar:=False, Temporary:=False)
Set the_command_bar_control = the_command_bar.Controls.Add
the_command_bar_control.Caption = "Add &Element"
the_command_bar_control.OnAction = "AddElement"
Set CreateSubMenu = the_command_bar
End Function
Sub ElementClick()
Set Element_Menu = CreateSubMenu
Element_Menu.ShowPopup
End Sub
Sub AddElement()
ActiveSheet.Shapes("Element").Select 'Selecting template object to replicate
ActiveSheet.Paste 'Inserting copy out from the clipboard
End Sub
Upvotes: 0
Views: 58
Reputation: 1048
Is the shape that is added correctly named "Element" (as per the line that does not work?) It seems that it is called "Test Element".
Upvotes: 1