- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 90
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2025-4-14
               
|
- Sub Auto_Open()
- Dim MyForm As VBComponent
- Set MyForm = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)
- With MyForm
- .Properties("Caption") = "Test_Form"
- .Name = "Test_Form1"
- With .Designer
- With .Controls.Add("Forms.CommandButton.1")
- .Top = 50
- .Left = 100
- .Height = 20
- .Width = 20
- .Caption = ">>"
- .Name = "Move_Data"
- End With
- For i = 1 To 2
- With .Controls.Add("Forms.Listbox.1")
- .Top = 10
- .Left = (i - 1) * 100 + 20
- .Height = 120
- .Width = 80
- .Name = "MyList" & i
- End With
- Next
- End With
- With .CodeModule
- .InsertLines 1, "Private Sub UserForm_Initialize()"
- .InsertLines 2, "MyList1.List=array(1,2,3,4,5,6,7,8,9)"
- .InsertLines 3, "End Sub"
- .InsertLines 4, "Private Sub Move_Data_Click()"
- .InsertLines 5, "x = MyList1.ListIndex"
- .InsertLines 6, "MyList2.AddItem MyList1.List(x)"
- .InsertLines 7, "MyList1.RemoveItem x"
- .InsertLines 8, "End Sub"
- End With
- End With
- With ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
- .InsertLines 1, "Private Sub Workbook_BeforeClose(Cancel As Boolean)" & Chr(10) & _
- "With ThisWorkbook" & Chr(10) & _
- ".VBProject.VBComponents.Remove .VBProject.VBComponents(""Test_Form1"")" & Chr(10) & _
- "n = .VBProject.VBComponents(""ThisWorkbook"").CodeModule.CountOfLines" & Chr(10) & _
- ".VBProject.VBComponents(""ThisWorkbook"").CodeModule.DeleteLines 1, n" & Chr(10) & _
- ".Save" & Chr(10) & _
- "End With" & Chr(10) & _
- "End Sub"
- End With
- 'OpenForm '¶}±ÒÀɮצ۰ʶ}±Òªí³æ
- End Sub
- Sub OpenForm()
- 'Test_Form1.Show 0 '¶}±Òªí³æ
- End Sub
½Æ»s¥N½X ¦^´_ 5# C.F
¬O³o¼Ëªº®ÄªG¶Ü?
°ÊºA·s¼Wªí³æ.zip (13.91 KB)
¤@¯ë¼Ò²Õ |
|