Follow Hyperlink

Daryl

Registered User.
Local time
Today, 17:46
Joined
May 22, 2001
Messages
34
I am trying to open Word documents when a button is pushed. The documents are located on a certain server in a specific master forms directory. Presumably, the documents are located in certain subdirectories based on their usage (or placement by the user). The message box in the following code shows the correct location of the document but when I try to run the followhyperlink procedure I get a run-time error. Any idea what I'm doing wrong or need to change to get this working is greatly appreciated.

Private Sub Command4615_Click()
'Set variables for lan directories relating to form field entries
Dim strMainDir As String 'Main directory
Dim strTerrID As String 'Subdirectory of Main directory
Dim strFormType As String ' Subdirectory of TerrID directory
Dim strFormID As String 'Subdirectory of FormType directory

strMainDir = "http://MFXDOCCDD01/Development/Business_Teams/Product_Development/TRIWAY FORMS/"
strTerrID = Me.TerrID
strFormType = Me.Form_Type
strFormID = Me.Form_nm & " " & Me.Form_vdt

'Open form
'MsgBox strMainDir & strTerrID & "/" & strFormType & "/" & strFormID & ".doc"
FollowHyperlink strMainDir & strTerrID & "/" & strFormType & "/" & strFormID & ".doc", , True


End Sub
 
I think you have to precede it with Application like:

Application.FollowHyperlink "path"

That is ensuring your paths are correct which I can't check for you!

Ian
 
I've tried your suggestion (and many other similar variations of code) but to no avail. The paths are correct. When I enter the location in a hypertext field it opens the Word document. I don't want to store all that information. Besides, it the client changes the master location of the documents it would be easier to change it in code.

I'll keep plugging away at it. If you come up with another idea, let me know.
 
I have used this method in the past, but without using a hyperlink field. I just had a string field which holds a file location.
I can assure you that it worked just fine like that.

If you like I can email you an example file.
Email me.

Ian
 
Thanks for the offer. Last night I would have said "Yes, please send it." But, the lightbulb came on this morning. Here's the solution I developed (I surprised myself).

Private Sub cmd_ViewForm_Click()
'Set variables for lan directories relating to form field entries
Dim strLinkFileID As String 'Complete network path and specific file info
strLinkFileID = "\\MFXDOCCDD01\Development\Business_Teams\Product_Development\TRIWAY_FORMS\" & _
Me.cbo_TerrID & "\" & Me.cbo_FormType & "\" & (Me.txtFormID & " " & Me.txtFormVersion & ".doc")

'Set hyperlink address to string
Me.cmd_ViewForm.HyperlinkAddress = strLinkFileID

'Follow hyperlink
Me.cmd_ViewForm.Hyperlink.Follow

End Sub

Now I need to develop code to check if the file exists and to pop up a message box when it doesn't. Any ideas how to do this would be appreciated.

Thanks for your input.
 

Users who are viewing this thread

Back
Top Bottom