Hello I am trying to open a specific word document depending on the record open.
I have got the code below to work OK, but this will only open a fixed document , in this case PM600.
My database has a reference call Property Number.
My word documents are saved in the format "PM" and then the [property number] - thus PM600
I guess I am trying to get the code to refer to the document path with the correct document reference.
I have tried:
'Path to the word document
LWordDoc = "m:\Back End\Inventories\&"PM"&[property number]&.doc"
But no good. Please could someone assist?
Many thanks Mark
WORKING CODE, BUT DOES NOT UPDATE THE DOCUMENT NAME:
MsgBox "Opening INVENTORY in Microsoft Word - Please Click OK to continue"
Dim LWordDoc As String
Dim oApp As Object
'Path to the word document
LWordDoc = "m:\Back End\Inventories\PM600.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
I have got the code below to work OK, but this will only open a fixed document , in this case PM600.
My database has a reference call Property Number.
My word documents are saved in the format "PM" and then the [property number] - thus PM600
I guess I am trying to get the code to refer to the document path with the correct document reference.
I have tried:
'Path to the word document
LWordDoc = "m:\Back End\Inventories\&"PM"&[property number]&.doc"
But no good. Please could someone assist?
Many thanks Mark
WORKING CODE, BUT DOES NOT UPDATE THE DOCUMENT NAME:
MsgBox "Opening INVENTORY in Microsoft Word - Please Click OK to continue"
Dim LWordDoc As String
Dim oApp As Object
'Path to the word document
LWordDoc = "m:\Back End\Inventories\PM600.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