I'm trying to get a button I've created dynamically on an excel userform form to run a macro called transfer
which I've written in Module 1
of the "Modules" section of my project.
Below I've pasted the code I've written so far in the userform which actually manages to create the Transfer to Sheet
button in the frame (which I've also created dynamically) but for some reason, when I run VBA I get a 438 error
message saying that Object doesn't support this property or method
.
Can anybody tell me how I can resolve this?
Here's the code:
Dim framecontrol1 As Control
Set workitemframe = Controls.Add("Forms.Frame.1")
With workitemframe
.Width = 400
.Height = 400
.Top = 160
.Left = 2
.ZOrder (1)
.Visible = True
End With
workitemframe.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 With
framecontrol1.OnAction = "transfer"