作者:乔山办公网日期:
返回目录:excel表格制作
在Thisworkbook中,添加如下代码:
Application.Visible = False'将Excel文件隐藏
淼森数据.show'根据实际窗体名字更改
End Sub
不可以
亲 将窗体的showModal属性设置成FALSE 即可互不影响!
Sub 创建窗体()
Dim UsForm As Object
Set regex = CreateObject("vbscript.regexp")
regex.Global = True
regex.Pattern = "\d+"
pagename = Sheet1.[a2].Resize(Sheet1.[a65535].End(xlUp).Row, 1)
Set d = CreateObject("scripting.dictionary")
Set d1 = CreateObject("scripting.dictionary")
i = 1
For Each ke In pagename
If Len(ke) > 0 Then
d(pagename(i, 1)) = ""
d1(regex.Replace(ke, "")) = ""
End If
i = i + 1
Next
Set pagename = Nothing
Set UsForm = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)'需引用Microsoft Forms 2.0 Object Library
With UsForm
.Properties("Caption") = Sheet1.[a1]
.Properties("Height") = 360
.Properties("Width") = 420
With .Designer
Set mympage = .Controls.Add("Forms.MultiPage.1")
With mympage
.Top = 2
.Height = UsForm.Properties("Height") - 50
.Width = UsForm.Properties("Width") - 20
.Left = 10
.BackColor = RGB(200, 200, 200)
End With
For Each ke1 In d1.keys
mympage.Pages.Add ke1 & "字头e799bee5baa6e4b893e5b19e338", ke1 & "字头"
i = 1
For Each ke2 In d.keys
If regex.Replace(ke2, "") = ke1 Then
Set objbtn = mympage.Pages(ke1 & "字头").Controls.Add("Forms.CommandButton.1")
With objbtn
.Top = 20 + 22 * (i - 1)
.Height = 20
.Width = 50
.Left = 18
.Caption = ke2
.BackColor = RGB(200, 200, 200)
End With
i = i + 1
End If
Next
Next
mympage.Pages.Remove ("Page1")
mympage.Pages.Remove ("Page2")
End With
End With
VBA.UserForms.Add(UsForm.Name).Show
ThisWorkbook.VBProject.VBComponents.Remove UsForm
Set UsForm = Nothing
Set regex = Nothing
Set objbtn = Nothing
End Sub