在Access 2013中使用VBA打开Word文档 [英] Opening Word Document using VBA in Access 2013

查看:401
本文介绍了在Access 2013中使用VBA打开Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using Access 2013 and created a help button on a form that I would like to open up a Word doc with instructions. Here's the code I tried:

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

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

The problem is, when I try to compile I get an error on the first line that says "User-defined type not defined"

推荐答案

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

Please check if you set appropriate reference to Word Library in VBA Environment.

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

To do so follow the path:

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.

这篇关于在Access 2013中使用VBA打开Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆