我有一个VBA程序,可以打开一系列用户表单。 我在笔记本电脑上设计了整个产品,并在其他笔记本电脑上进行了测试。在Excel 2010和2016中都有。
我与使用不同风格笔记本电脑的同事(Win7,Office 2010)分享了它。每次按下按钮打开用户窗体时,都会出现灾难性故障,内存不足错误。
我在网上看到模块应该低于64kb。用于打开按钮的模块非常小(只需打开UserForm1)。
Userform frm文件为4 KB。 Userform frx文件大小为1.24 MB,因为此表单上有图片等。
用户表单运行的代码。
Private Sub ComboBox1_DropButtonClick()
'Determines the controller model based off selection
If ComboBox1.Text = "VHX-6000 + VHX-A60E" Then
Controller = 6000
Else
Controller = 950
End If
'Updates textbox1 with current pricing info
TextBox1.Text = Application.VLookup(Controller, Sheet3.Range("A37:C45"), 2, 0)
End Sub
Private Sub Continue1_Click()
price = 0
'Determines if it should show the camera page based on the controller selection
If Controller = 6000 Then
CameraForm.Show
Else
Camera = 6020
StageForm.Show
End If
End Sub
Private Sub Image6_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As MSForms.fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)
End Sub
Private Sub Label2_Click()
End Sub
Private Sub UserForm_Activate()
'Make Sheet 3 activate to avoid that weird error message towards the end
Worksheets("sheet3").Activate
'Sets the dropdown list
ComboBox1.List() = Sheet3.Range("C6:C7").Value
'Clears the quote information if present
Sheet3.Range("M51:O100").ClearContents
Controller = 0
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
'Full Screen
With Me
.Width = Application.Width
.Height = Application.Height
End With
End Sub
没什么可继续的:
要加载表单,我在Sheet3代码窗口中有一个命令按钮OLE对象的代码:
Private Sub CommandButton1_Click()
Load ControllerForm
ControllerForm.Show
End Sub
请注意与您的代码有两点不同:
Sub Button1_Click()
ControllerForm.Show
End Sub
Load ControllerForm
吗?