link to microsoft word

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello every one

I have this code from Northwind sample.

Private Sub ReviewProducts_Click()
' This code created in part by Command Button Wizard.
On Error GoTo Err_ReviewProducts_Click

Dim strMsg As String, strTitle As String
Dim intStyle As Integer
Dim strDocName As String, strLinkCriteria As String

' If CompanyName control is blank, display a message.
If IsNull(Me![CompanyName]) Then
strMsg = "Move to the supplier record whose products you want to
see, then press the Review Products button again."
intStyle = vbOKOnly
strTitle = "Select a Supplier"
MsgBox strMsg, intStyle, strTitle
Me![CompanyName].SetFocus
Else
' Otherwise, open Product List form, showing products for current
supplier.
strDocName = "Product List"
strLinkCriteria = "[SupplierID] = Forms![Suppliers]![SupplierID]"
DoCmd.OpenForm strDocName, , , strLinkCriteria
End If

Exit_ReviewProducts_Click:
Exit Sub

Err_ReviewProducts_Click:
MsgBox Err.Description
Resume Exit_ReviewProducts_Click

End Sub

this will open another form with the same criteria.

what if i want to open a word document.
I want to use this for a (number) field.called "ourref"
suppose the office ducuemnt is located in D:\MyFiles\Word
and file names are serial numbers like 1,2,3

if the OurRef Number is 1.
then , if i double click this field , i want the code to open the word
docuemnt from the above location with the file name "1"

any help on this will be highly appriciated.
 
Followhyperlink permits you to open any file using the default application
associated with it.

Something like the following should work.

dim strFolder as string
strFolder = "D:\MyFiles\Word"
Application.FollowHyperlink strFolder & Mr.OurRef & ".doc"

Daniel
 
Not to be short but go to the Access.Programming news group and do a search
for "Open a Word document". You should get pleanty of good ideas and help.
 
Thanks to both of you. I have tried the code and to works perfect.thanks

Mr b , actually , I was not knowing the key word to search , as i thought
that writting open word document will give me openning a blank word file.
thank you any way for response.
 
mhmaid,

The reason for my suggestion that you do the search was to try to show you
that you can do a lot of things when opening a Word document. The
possibilities are almost endless.

Just trying to broaden the horizen.
 
Back
Top