0
我正在嘗試創建彈出式菜單,它將提供從名爲「元素」(橢圓形+文本框)的形狀組中複製粘貼形狀對象的選項。 但似乎Select &粘貼方法不起作用。彈出窗口中的代碼不會影響工作表元素
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
好點。此外,不要硬編碼名稱,而是使用'nam'變量。 –
我改變了有關問題的信息。看到最初的消息。 Subroutine AddElement()中沒有任何參數的結果相同。 –
對不起,沒有參數(因爲它現在在上面的消息中)宏正在工作! –