将表单文本框值写入 Word 文档不起作用
我有一个用于文本短语的用户表单,我想在关闭用户表单时保存输入的短语。由于某种原因它不起作用。
这是我的代码:
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
有人知道我的代码有什么问题吗?
I have a user form for text phrases and I want to save the entered phrases upon closing the user form. For some reason it does not work.
Here is my code:
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
On initilization of user form I have the following code:
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
Does anyone know what's wrong with my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
UserForm1.Hide
You could use
UserForm1.Hide