您好,我在尝试自动使用从MS Access表单计算出的数据填充Word文档时遇到了麻烦。 我一直在关注这段YouTube视频:https://www.youtube.com/watch?v=k176qcg-YCo,当我运行代码时,它会打开单词,但会陷入循环,我相信。单击该按钮时将调用该函数,下面提供了代码。非常感谢您的帮助!
Function fillwordform()
Dim appword As Word.Application
Dim doc As Word.Document
Dim Path As String
On Error Resume Next
Error.Clear
Set appword = GetObject(, "word.application")
If Err.Number <> 0 Then
Set appword = New Word.Application
appword.Visible = True
End If
Path = "C:\Users\Jay\Documents\Monthly Update.docx"
Set doc = appword.Documents.Open(Path, , True)
With doc
.FormFields("ItmRec").Result = Me.NVCItmRcv
appword.Visible = True
appword.Activate
End With
Set doc = Nothing
Set appword = Nothing
End Function
“ ItmRec”是试图填充Word的文本框的名称,而“ Me.NVCItmRcv”是我要从中提取数字并将其放入文本框的框的名称。如果您需要更多详细信息或其他任何信息,请告诉我!再次感谢您的帮助!