Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening word document liked to a specific record 1

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
584
GB
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
 
Try:
[tt]
LWordDoc = "m:\Back End\Inventories\PM" & [property number] & ".doc"
[/tt]

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top