[英]Opening Word Document using VBA in Access 2013
我正在使用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
問題是,當我嘗試編譯時,第一行出現錯誤,提示“未定義用戶定義類型”
這樣做不會更容易:
Shell "winword ""c:\...\Handout.docx"""
...而不是僅僅為了打開應用程序而創建對象?
請檢查是否在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.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.