Access: Open a Microsoft Word document from Access 2003/XP/2000/97
Question: How can I open a particular Microsoft Word document from an Access 2003/XP/2000/97 database?
For example, I have a filed called "Doc1.doc" that I want to open. How can I do this?
Answer: From your Access database, you can open any Word document that you wish.
The following VBA code would open a document called "Doc1.doc" from Access. This file can be found under the following path: "c:\Doc1.doc".
Private Sub Command1_Click()
Dim LWordDoc As String
Dim oApp As Object'Path to the word document
LWordDoc = "c:\Doc1.doc"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:=LWordDoc
End IfEnd Sub
In this example, we've created a button called Command1. When the user clicks this button, the VBA code will open a session of Microsoft Word and display the Word document called "Doc1.doc".
To learn how to launch Microsoft Excel from Access, click here.
To learn how to launch Notepad from Access, click here.
To learn how to launch any application from Access, click here.