totn Access

MS Access 2003: Open a Microsoft Word document from Access

This MSAccess tutorial explains how to open a Microsoft Word document from within Access 2003 (with step-by-step instructions).

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 If

End 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".

This MSAccess tutorial explains how to launch Microsoft Excel from Access.

This MSAccess tutorial explains how to launch Notepad from Access.

This MSAccess tutorial explains how to launch any application from Access.