【发布时间】:2020-11-29 17:14:12
【问题描述】:
我在 access 中创建了一个表单,我正在尝试编写一个“合并到单词”按钮,但我的代码有问题,我不知道如何解决它。
代码如下:
Private Sub Command102_Click()
Dim LWordDoc As String
Dim oApp As Object
'Path to the word document
LWordDoc = "C:\school\information tech\document.docx"
If Dir(LWordDoc) = "" Then
MsgBox "Document not found."
Else
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True
'Open the Document
oApp.Documents.Open FileName:=Document.docx
End If
End Sub
如果有人可以提供帮助,那就太好了。我将附上当我单击按钮时出现的错误的屏幕截图,以及调试器指向问题的代码。 (指向“oApp.Documents.Open FileName:=Document.docx”行的开头)
谢谢大家
【问题讨论】:
标签: vba ms-access merge ms-word