Openig a text file (dynamically) using hyperlink?

IanMilly

Registered User.
Local time
Today, 01:13
Joined
Jun 1, 2004
Messages
46
Hi,

I am trying to open a text file using a button which is set as a hyperlink. The file location will stay the same however the name of the file will change dependant upon a previous value in another field (basically this is serial numbering with referencing to a set history log).


I have tried a few things to change the name of the text file that will be opened (it is a read-only file), non of which worked (i might have been close, not seeing the wood for the trees!). How can i change the name of the hyperlink easily to match the value in another field or is there a better way to open the files when called upon?

Thanks

Ian
 
Code:
Application.FollowHyperlink "C:\YourFolder\" & Me.YourTextBox & ".txt", , True, True
HTH
 
thanks

:) brilliant, thanks alot, i was fairly close all along, so frustrating when its like that!

thanks again :)

ian
 
No probs. Don't forget to trap errors...
Code:
Private Sub YourButton_Click()
On Error GoTo Err_YourButton_Click

            Application.FollowHyperlink "C:\YourFolder\" & Me.YourTextBox & ".txt", , True, True
    
Exit_YourButton_Click:
    Exit Sub
    
Err_YourButton_Click:
    If IsNull(Me.YourTextBox) Then
        MsgBox "There is no file listed."
    Else
        MsgBox "The file does not exist in this folder"
    End If
    Resume Exit_YourButton_Click

End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom