ms-access - 在 Access 2013 中使用 VBA 打开 Word 文档

标签 ms-access ms-word vba

我正在使用 Access 2013 并在表单上创建了一个帮助按钮,我想打开一个带有说明的 Word 文档。这是我试过的代码:

Private Sub cmdHelp_Click()
    Dim wrdApp As Word.Application
    Dim wrdDoc As Word.Document
    Dim filepath As String

    Set wrdApp = CreateObject("Word.Application")
    wrdApp.Visible = True

    filepath = "C:\...\Handout.docx"
    Set wrdDoc = wrdApp.Documents.Open(filepath)
End Sub

问题是,当我尝试编译时,第一行出现“未定义用户定义类型”的错误

最佳答案

请检查您是否在 VBA 环境中设置了对 Word 库的适当引用。

要这样做,请遵循以下路径:

Go to VBA Editor >> Menu >> Tools >> References >> 
    Find on the list Microsoft Word XX.X Object Library where 
    XX.X is the highest available number >> 
Check it >> press OK.

关于ms-access - 在 Access 2013 中使用 VBA 打开 Word 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17973041/

相关文章:

java - 通过迭代插入记录以不规则顺序创建记录

java - 创建 jdbc odbc 连接而不在 MS ACCESS 中创建 DSN

php - 我正在用 PHP 生成一个 word 文档,如何进行分页?

wpf - 修改文档 "template"并通过 WPF 打印的最简单方法?

excel - 如何从即时窗口调用 Excel 自定义功能区按钮?

excel - 如何插入嵌入图片?

database - 如何在 Visual Studio 2008 中连接到 Access 2007 (accdb) 文件

ms-word - 在 MS Word 字段中显示日期差异

vba - Excel-VBA : Find and Replace and Date Formatting from String

vba - 数组、匹配、排序