Excel 灾难性故障-打开用户窗体时内存不足
我有一个VBA程序,可以打开一系列用户窗体。 我在我的笔记本电脑上设计了整个系统,并在其他一些笔记本电脑上进行了测试。在Excel 2010和2016中 我与使用不同风格的笔记本电脑Win7、Office 2010的同事分享了它。每次点击按钮打开userform时,他们都会遇到一个灾难性的故障,即内存不足错误 我在网上看到模块应该小于64kb。用于打开按钮的模块非常小,只是打开了UserForm1 Userform frm文件的大小为4KB。 Userform frx文件为1.24 MB,更大,因为此表单上有图片等 用户窗体运行的代码Excel 灾难性故障-打开用户窗体时内存不足,excel,vba,out-of-memory,Excel,Vba,Out Of Memory,我有一个VBA程序,可以打开一系列用户窗体。 我在我的笔记本电脑上设计了整个系统,并在其他一些笔记本电脑上进行了测试。在Excel 2010和2016中 我与使用不同风格的笔记本电脑Win7、Office 2010的同事分享了它。每次点击按钮打开userform时,他们都会遇到一个灾难性的故障,即内存不足错误 我在网上看到模块应该小于64kb。用于打开按钮的模块非常小,只是打开了UserForm1 Userform frm文件的大小为4KB。 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对象的代码:
请注意代码中的两个差异:
Sub Button1_Click()
ControllerForm.Show
End Sub
您是否需要使用Load ControlPerform?
这些按钮之间有区别:Commandbutton1和Button1。您的按钮1是msoFormControl 8,而我的按钮是msoOLEControlObject12。
看
感谢这是一个旧的线程,但我有一个类似的问题,这已导致我头痛了几个小时 我一直在使用双监视器,并设置了半打用户表单 如果我在没有连接任何显示器的情况下打开笔记本电脑上的一些用户表单,我会得到一个戏剧性的“灾难性的失败” 我发现问题与显示设置中的屏幕比例有关。我的显示器是100%,笔记本电脑是125%
当我把笔记本电脑换成100%的时候。。。瞧。一切正常。老实说有点傻,但觉得值得一提嗯,听起来好像有一个递归调用在那里的某个地方打开了表单。在它崩溃之前,您不会看到它,因为您已经绑定了消息泵线程。您是否获得了Application.Width和Application.Height的合理值?如果你的图像是自动缩放的,比如说,它们是最大值,那就可以了。@Comintern试图删除重新缩放图像的部分,但仍然得到相同的错误:/@RobertHarvey你能详细说明一下吗?很抱歉,我有点像n00b,一直在自学。我很感谢你的帮助,只是我不完全理解你的建议。你知道什么是递归吗?
Sub Button1_Click()
ControllerForm.Show
End Sub