Set MyNewForm3 = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)
Print #1, Now & " 開始建立 UserForm"
With MyNewForm3
.Properties("Caption") = "Report_Generate"
.Properties("Width") = 570
.Properties("Height") = 350
.Name = "Report_Generate_Form"
With .Designer
With .Controls.Add("forms.Multipage.1")
.Name = "MultiPage_Step"
.Left = 10
.Top = 5
.Height = 250
.Width = 550
.Font.Name = "Comic Sans MS"
End With
之後就 Multipage 中的 Page(0)、Page(1)中新增了一些控制項
With .Controls.Add("forms.CommandButton.1")
'建立個 Button 來按一步讓 MultiPage 到下一頁
.Name = "GoNext_Btn"
.Left = 280
.Top = 258
.Height = 50
.Width = 70
.Caption = "下一步"
.Font.Name = "標楷體"
.Font.Size = 14
End With
End With
Set Class_obj3.MyFormObject1 = MyNewForm3 '.Designer
Set Class_obj3.MyMultiPage1 = MyNewForm3.Designer.Controls("MultiPage_Step")
然後利用 Class 方式執行動作
With .CodeModule
.InsertLines i + 4, "Set Class_obj3.MyNewGoNextButton1 = Controls(""GoNext_Btn"")"
End With
End With
Class 3 的內容
Public MyFormObject1 As Object
Public MyMultiPage1 As MSForms.MultiPage
Private Sub MyNewGoNextButton1_Click()
With MyMultiPage1