如何将输入表单中的数据保存到出现宏的Word文档中?

时间:2019-07-08 15:11:37

标签: vba ms-word

我需要在宏终止后将输入到Word表单中的数据保存在VBA中。我有一个输入表单,其中包含大约40个字段,其中包含姓名,地址,电话号码等,我不希望用户再次输入所有内容,以防万一他们意识到自己犯了一个错误并需要更改一项。当前,宏在窗体关闭时删除所有输入到窗体的数据。 Word文档具有一个用于调用输入表单的命令按钮,并且由于该表单将存储在云服务器上,因此我需要使用宏来保存已输入到调用输入表单的Word文档中的数据。

我在论坛和Google上四处逛逛,但没有任何运气。

'''此代码打开我的表单。命令按钮位于Word文档中,我需要在其中保存已输入的数据。

Private Sub CommandButton1_Click()

    InputForm.Show vbModeless
End Sub

这段代码关闭了我的表单,目前,它会擦除​​所有已输入的数据

Private Sub CloseForm_Click()

    Dim Closing As Integer
    Closing = MsgBox("This will exit the form and erase all the data that has been input. You may want to review the documents to ensure they were generated correctly before closing the form. Click Yes to proceed to close the form or No to go back to the form.", vbYesNo + vbQuestion, "Exit Confirmation")
    If Closing = vbYes Then
        Unload InputForm 'This closes the Input Form and returns the user to Word
    End If
End Sub

宏终止时,它将删除所有已输入的数据。我需要它来将数据保存在调用输入表单的Word文档中。

0 个答案:

没有答案