Opening Word Document using VBA in Access 2013
34,955
Solution 1
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.
Solution 2
Wouldn't be easier just to do:
Shell "winword ""c:\...\Handout.docx"""
... instead of creating an object just to open the application?
Author by
user2521720
Updated on May 14, 2020Comments
-
user2521720 about 4 years
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"
-
Fionnuala over 7 yearsIt is nearly always better to develop with early binding and release with late binding.