我的代码将从工作表中获取数据并根据它生成表单,但我无法弄清楚如何在创建表单后“保存”表单。这是生成表单的代码。
Sub UFInit()
Dim i As Long 'Counter to keep standardized checkbox names
Dim r As Range 'Range of cells to get checkbox captions
Dim cell As Range 'For the loop
Dim cb As MSForms.CheckBox 'Checkbox
Dim t As Double 'Top position for a checkbox
Dim l As Double 'Left position for a checkbox
Set r = Sheets("Sheet4").Range("A1:AAA100").SpecialCells(xlCellTypeConstants) 'Where my range is for captions
i = 1
For Each cell In r
Set cb = UserFormX.controls.Add("Forms.Checkbox.1", "CheckBox" & i, True)
cb.Caption = cell.Value
cb.Name = Replace(Replace(cb.Caption, " ", ""), "-", "")
cb.Top = cell.Row * 12.75
cb.Left = 150 + cell.Column * 9.5
If cell.Row * 12.75 > t Then t = (cell.Row * 12.75)
If cell.Column * 9.5 > l Then l = (cell.Column * 10)
i = i + 1
Next cell
UserForm1.Show
End Sub