【问题标题】:My access to word merge code is not working我无法访问单词合并代码
【发布时间】: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


    【解决方案1】:

    既然您创建了一个变量来保存文件名,请尝试使用它:

    oApp.Documents.Open FileName:=LWordDoc
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-06
      • 2011-12-23
      • 2017-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多