我正在尝试在加载附带的Word文档模板时打开用户窗体。
现在,我在excel中有一个代码和一个按钮,可以打开我要使用的doc模板字样。在该模板中,我还具有一个有效的用户功能,可让我输入所需的所有内容并将其输入doc一词。我的问题是我正在尝试打开文档时弹出用户窗体。我不知道这是否可行,但任何帮助将不胜感激
我的用户表单的代码如下
Private Sub CommandButton1_Click()
Dim Date_30daysbeforeshipment As Range
Set Date_30daysbeforeshipment = ActiveDocument.Bookmarks("Date_30daysbeforeshipment").Range
Date_30daysbeforeshipment.Text = Me.TextBox1.Value
Dim Job_Number_and_Name As Range
Set Job_Number_and_Name = ActiveDocument.Bookmarks("Job_Number_and_Name").Range
Job_Number_and_Name.Text = Me.TextBox2.Value
Dim Quantity_Of_Product_needed As Range
Set Quantity_Of_Product_needed = ActiveDocument.Bookmarks("Quantity_Of_Product_needed").Range
Quantity_Of_Product_needed.Text = Me.TextBox3.Value
Dim Product_Matrix As Range
Set Product_Matrix = ActiveDocument.Bookmarks("Product_Matrix").Range
Product_Matrix.Text = Me.TextBox4.Value
Me.Repaint
testform.Hide
End Sub
Private Sub Label2_Click()
End Sub
Private Sub UserForm_Click()
testform.Hide
End Sub
Private Sub UserForm_Initialize()
End Sub
文档本身的代码为:
Private Sub AutoExec()
testform.Show
End Sub
我想要的是我在打开文档时打开的用户窗体。目前,我还没有收到任何错误,只是没有认真阅读我的文档,我必须进入VBA并手动运行它才能工作。