运行-time error 13 修复后 运行-time error 91
Run-time error 13 and after fix Run-time error 91
您好,我的程序有问题。
我正在尝试从我的 UserForm1 打开 UserForm2,但我需要在显示之前为 UserForm2 初始化一些代码。
我在我的代码中使用了 UserForm2.Show
并通过 Show UserForm2
从 UserForm1 打开它这工作正常但是当关闭它时给我错误 91.
我试图删除 UserForm2.Show
但这导致 UserForm2 没有加载并给我错误 13。
这是我的代码
模块 1:
Option Explicit
Public ListName As String
用户窗体 1:
Private Sub CommandButton1_Click()
If CheckBox5.Value = False And CheckBox6.Value = False Then
MsgBox ("Nebyla zvolena operace.")
GoTo Ukoncit
End If
If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox4.Value = False Then
MsgBox ("Nebyl zvolen list.")
GoTo Ukoncit
End If
If CheckBox5.Value = True Then
End If
If CheckBox6.Value = True Then
If CheckBox1.Value = True Then
ListName = "SAP_CZ"
ElseIf CheckBox2.Value = True Then
ListName = "SAP_CH"
ElseIf CheckBox3.Value = True Then
ListName = "Datab_1"
ElseIf CheckBox4.Value = True Then
ListName = "Datab_2"
End If
Show UserForm2 ' <------------- Here is Opening UserForm2
End If
Ukoncit:
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
CheckBox2.Enabled = False
CheckBox3.Enabled = False
CheckBox4.Enabled = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
End If
If CheckBox1.Value = False Then
CheckBox2.Enabled = True
CheckBox3.Enabled = True
CheckBox4.Enabled = True
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
End If
End Sub
Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
CheckBox1.Enabled = False
CheckBox3.Enabled = False
CheckBox4.Enabled = False
CheckBox1.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
End If
If CheckBox2.Value = False Then
CheckBox1.Enabled = True
CheckBox3.Enabled = True
CheckBox4.Enabled = True
CheckBox1.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox3.Value = True Then
CheckBox2.Enabled = False
CheckBox1.Enabled = False
CheckBox4.Enabled = False
CheckBox2.Value = False
CheckBox1.Value = False
CheckBox4.Value = False
End If
If CheckBox3.Value = False Then
CheckBox2.Enabled = True
CheckBox1.Enabled = True
CheckBox4.Enabled = True
CheckBox2.Value = False
CheckBox1.Value = False
CheckBox4.Value = False
End If
End Sub
Private Sub CheckBox4_Click()
If CheckBox4.Value = True Then
CheckBox2.Enabled = False
CheckBox3.Enabled = False
CheckBox1.Enabled = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox1.Value = False
End If
If CheckBox4.Value = False Then
CheckBox2.Enabled = True
CheckBox3.Enabled = True
CheckBox1.Enabled = True
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox1.Value = False
End If
End Sub
Private Sub CheckBox5_Click()
If CheckBox5.Value = True Then
CheckBox6.Enabled = False
CheckBox6.Value = False
End If
If CheckBox5.Value = False Then
CheckBox6.Enabled = True
CheckBox6.Value = False
End If
End Sub
Private Sub CheckBox6_Click()
If CheckBox6.Value = True Then
CheckBox5.Enabled = False
CheckBox5.Value = False
End If
If CheckBox6.Value = False Then
CheckBox5.Enabled = True
CheckBox5.Value = False
End If
End Sub
UserForm2 给出错误 91:
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim Label1String As String
Label1String = "Chcete opravdu smazat data z listu " & ListName
UserForm2.Label1.Caption = Label1String
UserForm2.Show
End Sub
UserForm2 给出错误 13:
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim Label1String As String
Label1String = "Chcete opravdu smazat data z listu " & ListName
UserForm2.Label1.Caption = Label1String
End Sub
这个错误是由Show UserForm2
引起的
应该是
UserForm2.Show
而且你不需要在你的 UserForm_Initialize sub
中有这个
我编辑了这段代码,将代码从 Initialize 提供给 Activat,删除了 UserForm1.Show
并将 Unload Me
替换为 Hide
现在代码在 UserForm2 中:
Private Sub CommandButton1_Click()
Hide
End Sub
Private Sub UserForm_Activate()
Dim Label1String As String
Label1String = "Chcete opravdu smazat data z listu " & ListName
UserForm2.Label1.Caption = Label1String
End Sub
但仍在 UserForm1 行中 Show UserForm2
出现运行时错误 13。
您好,我的程序有问题。 我正在尝试从我的 UserForm1 打开 UserForm2,但我需要在显示之前为 UserForm2 初始化一些代码。
我在我的代码中使用了 UserForm2.Show
并通过 Show UserForm2
从 UserForm1 打开它这工作正常但是当关闭它时给我错误 91.
我试图删除 UserForm2.Show
但这导致 UserForm2 没有加载并给我错误 13。
这是我的代码
模块 1:
Option Explicit
Public ListName As String
用户窗体 1:
Private Sub CommandButton1_Click()
If CheckBox5.Value = False And CheckBox6.Value = False Then
MsgBox ("Nebyla zvolena operace.")
GoTo Ukoncit
End If
If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox4.Value = False Then
MsgBox ("Nebyl zvolen list.")
GoTo Ukoncit
End If
If CheckBox5.Value = True Then
End If
If CheckBox6.Value = True Then
If CheckBox1.Value = True Then
ListName = "SAP_CZ"
ElseIf CheckBox2.Value = True Then
ListName = "SAP_CH"
ElseIf CheckBox3.Value = True Then
ListName = "Datab_1"
ElseIf CheckBox4.Value = True Then
ListName = "Datab_2"
End If
Show UserForm2 ' <------------- Here is Opening UserForm2
End If
Ukoncit:
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
CheckBox2.Enabled = False
CheckBox3.Enabled = False
CheckBox4.Enabled = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
End If
If CheckBox1.Value = False Then
CheckBox2.Enabled = True
CheckBox3.Enabled = True
CheckBox4.Enabled = True
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
End If
End Sub
Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
CheckBox1.Enabled = False
CheckBox3.Enabled = False
CheckBox4.Enabled = False
CheckBox1.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
End If
If CheckBox2.Value = False Then
CheckBox1.Enabled = True
CheckBox3.Enabled = True
CheckBox4.Enabled = True
CheckBox1.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox3.Value = True Then
CheckBox2.Enabled = False
CheckBox1.Enabled = False
CheckBox4.Enabled = False
CheckBox2.Value = False
CheckBox1.Value = False
CheckBox4.Value = False
End If
If CheckBox3.Value = False Then
CheckBox2.Enabled = True
CheckBox1.Enabled = True
CheckBox4.Enabled = True
CheckBox2.Value = False
CheckBox1.Value = False
CheckBox4.Value = False
End If
End Sub
Private Sub CheckBox4_Click()
If CheckBox4.Value = True Then
CheckBox2.Enabled = False
CheckBox3.Enabled = False
CheckBox1.Enabled = False
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox1.Value = False
End If
If CheckBox4.Value = False Then
CheckBox2.Enabled = True
CheckBox3.Enabled = True
CheckBox1.Enabled = True
CheckBox2.Value = False
CheckBox3.Value = False
CheckBox1.Value = False
End If
End Sub
Private Sub CheckBox5_Click()
If CheckBox5.Value = True Then
CheckBox6.Enabled = False
CheckBox6.Value = False
End If
If CheckBox5.Value = False Then
CheckBox6.Enabled = True
CheckBox6.Value = False
End If
End Sub
Private Sub CheckBox6_Click()
If CheckBox6.Value = True Then
CheckBox5.Enabled = False
CheckBox5.Value = False
End If
If CheckBox6.Value = False Then
CheckBox5.Enabled = True
CheckBox5.Value = False
End If
End Sub
UserForm2 给出错误 91:
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim Label1String As String
Label1String = "Chcete opravdu smazat data z listu " & ListName
UserForm2.Label1.Caption = Label1String
UserForm2.Show
End Sub
UserForm2 给出错误 13:
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim Label1String As String
Label1String = "Chcete opravdu smazat data z listu " & ListName
UserForm2.Label1.Caption = Label1String
End Sub
这个错误是由Show UserForm2
应该是
UserForm2.Show
而且你不需要在你的 UserForm_Initialize sub
中有这个我编辑了这段代码,将代码从 Initialize 提供给 Activat,删除了 UserForm1.Show
并将 Unload Me
替换为 Hide
现在代码在 UserForm2 中:
Private Sub CommandButton1_Click()
Hide
End Sub
Private Sub UserForm_Activate()
Dim Label1String As String
Label1String = "Chcete opravdu smazat data z listu " & ListName
UserForm2.Label1.Caption = Label1String
End Sub
但仍在 UserForm1 行中 Show UserForm2
出现运行时错误 13。