我有一个用于文本短语的用户表单,我想在关闭用户表单时保存输入的短语。由于某种原因,它不起作用。
这是我的代码:
Private Sub CancelButton_Click()
ActiveDocument.Variables("SPE 1") = UserForm1.TextBox1.Value
ActiveDocument.Variables("SPE 2") = UserForm1.TextBox2.Value
ActiveDocument.Variables("SPE 3") = UserForm1.TextBox3.Value
ActiveDocument.Variables("SPE 4") = UserForm1.TextBox4.Value
ActiveDocument.Variables("SPE 5") = UserForm1.TextBox5.Value
ActiveDocument.Variables("QAS 1") = UserForm1.TextBox6.Value
ActiveDocument.Variables("QAS 2") = UserForm1.TextBox7.Value
ActiveDocument.Variables("GPE 1") = UserForm1.TextBox8.Value
ActiveDocument.Variables("GPE 2") = UserForm1.TextBox9.Value
Unload UserForm1
End Sub
在初始化用户表单时,我有以下代码:
Sub UserForm1_Initialize()
UserForm1.TextBox1.Value = ActiveDocument.Variables("SPE 1").Value
UserForm1.TextBox2.Value = ActiveDocument.Variables("SPE 2").Value
UserForm1.TextBox3.Value = ActiveDocument.Variables("SPE 3").Value
UserForm1.TextBox4.Value = ActiveDocument.Variables("SPE 4").Value
UserForm1.TextBox5.Value = ActiveDocument.Variables("SPE 5").Value
UserForm1.TextBox6.Value = ActiveDocument.Variables("QAS 1").Value
UserForm1.TextBox7.Value = ActiveDocument.Variables("QAS 2").Value
UserForm1.TextBox8.Value = ActiveDocument.Variables("GPE 1").Value
UserForm1.TextBox9.Value = ActiveDocument.Variables("GPE 2").Value
End Sub
有谁知道我的代码有什么问题?