0
我有一個用於用戶表單的文本短語,我想在關閉用戶表單時保存輸入的短語。由於某種原因,它不起作用。將表單文本框值寫入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
有誰知道什麼是錯我的代碼?
看來問題就是命令「卸載」。其實我想保留條目而不是卸載它們。如何關閉不使用「卸載」的用戶表單? – user366121 2011-02-01 13:45:56