Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim NewButton As MSForms.CommandButton
' Add a CommandButton
Set NewButton = MyForm.Designer.Controls _
.Add("forms.CommandButton.1")
With NewButton
.Caption = "Click Me"
.Left = 60
.Top = 40
End With
' Add an event-hander sub for the CommandButton
With MyForm.CodeModule
' ** Delete This: TextLocation = .CreateEventProc("Click","CommandButton1")
' ** Add/change next 5 lines
' This code adds the commands/event handlers to the form
X = .CountOfLines
.InsertLines X + 1, "Sub CommandButton1_Click()"
.InsertLines X + 2, "MsgBox ""Hello!"""
.InsertLines X + 3, "Unload Me"
.InsertLines X + 4, "End Sub"
End With
Dim MyForm As Object
Dim FormName As String
' Create the UserForm
Set MyForm = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)
'Set Properties for MyForm
With MyForm
.Properties("Caption") = "My Form"
.Properties("Width") = 200
.Properties("Height") = 100
'Set all properties to your wishes
End With
FormName = MyForm.Name
.
.
.
'To disply the form
VBA.UserForms.Add(FormName).Show
.Name
Sub CommandButton1_Click()
Sub MyButton_Click()