Discussion Locked

Open word doc from Access

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a datbase listing of Word Documents. How can I open the documents from Access.
The database list the file name(without the doc extention) the title, the model it covers and the date released. I need to have a person be able to search for the document related to a specific model. Then I want them to be able to select a document and view or print in word. I can open Word from Access but how do I feed the file name to it?
Dennis

3 replies

by peyison

The following VBA code should do what you're looking for:

Public Sub OpenWordDoc(asFileName As String)
Dim WordApp As Object

'-- Create instance of Word
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True

'--open the file
WordApp.Documents.Open FileName:=asFileName & ".doc"

Set WordApp = Nothing
End Sub

Hope this helps.

This discussion is closed to new replies.