【发布时间】:2020-06-17 05:55:08
【问题描述】:
我有一个 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
【问题讨论】:
-
嗯,听起来您对表单的递归调用在某处打开。在它崩溃之前你不会看到它,因为你已经绑定了消息泵线程。
-
您是否获得了
Application.Width和Application.Height的合理值?如果您的图像是自动缩放的,并且它们是 MAX_INT,那么可以做到。 -
@Comintern 尝试删除重新调整它的部分,但仍然出现相同的错误:/
-
@RobertHarvey 你能详细说明一下吗?很抱歉,我有点不合群,并且一直在自学所有这些。感谢您的帮助,只是不完全理解您的建议。
-
你知道什么是递归吗?
标签: excel vba out-of-memory