- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 256
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2024-11-26
|
- Public obj As New Class1
- Sub Auto_Open()
- Dim MyForm As VBComponent
- For Each vbc In ThisWorkbook.VBProject.VBComponents
- If vbc.Type = 3 Then 'Àˬdªí³æ¼Ò²Õ
- If vbc.Name = "Test_Form1" Then Exit Sub '¦³¸Óªí³æ«h¸õ¥Xµ{§Ç
- End If
- Next
- Set MyForm = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm) '·s¼Wªí³æ¼Ò²Õ
- With MyForm
- .Properties("Caption") = "Test_Form" 'ªí³æ¼ÐÃD
- .Name = "Test_Form1" 'ªí³æ¦WºÙ
- With .Designer
- With .Controls.Add("Forms.CommandButton.1") '·s¼W«ö¶s
- .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") '²M³æ
- .Top = 10
- .Left = (i - 1) * 100 + 20
- .Height = 120
- .Width = 80
- .Name = "MyList" & i
- End With
- Next
- End With
- With .CodeModule '¦bªí³æ¼Ò²Õ¤º·s¼Wµ{§Ç
- .InsertLines 1, "Private Sub UserForm_Initialize()"
- .InsertLines 2, "MyList1.List=array(1,2,3,4,5,6,7,8,9)"
- .InsertLines 3, "Set obj.MyBut = Controls(""Move_Data"")" '±N«ö¶s¥[¤Jª«¥óÃþ§O
- .InsertLines 4, "End Sub"
- End With
- End With
- With ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule '¼g¤JÃö³¬ÀÉ®×µ{§Çªºµ{¦¡½X
- .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 ¦^´_ 10# C.F
À³¸Ó¬O§Aªºªí³æ¤w¸g¦s¦b¡A¦Ó§A¦b¤@¦¸°õ¦æ¸Óµ{§Ç¡A²£¥Í¦WºÙ½Ä¬ð
¸Õ¸Õ¬Ý |
|