将代码分配给动态创建的按钮
我正在尝试获取一个我在excel userform表单上动态创建的按钮来运行一个宏transfer
,我在Module 1
项目的“模块”部分写了这个宏。
下面我已经粘贴了我迄今为止在userform中编写的代码,它实际上设法Transfer to Sheet
在框架中创建按钮(我也是动态创建的)但是出于某种原因,当我运行VBA时,我得到一条438 error
消息说Object doesn't support this property or method
。
谁能告诉我怎么解决这个问题?
这是代码:
Dim framecontrol1 As ControlSet workitemframe = Controls.Add("Forms.Frame.1")With workitemframe .Width = 400 .Height = 400 .Top = 160 .Left = 2 .ZOrder (1) .Visible = TrueEnd Withworkitemframe.Caption = "Test"Set framecontrol1 = workitemframe.Controls.Add("Forms.commandbutton.1")With framecontrol1 .Width = 100 .Top = 70 .Left = 10 .ZOrder (1) .Visible = True .Caption = "Transfer to Sheet"End Withframecontrol1.OnAction = "transfer"
MM们
相关分类