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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyper Linking Documents

Status
Not open for further replies.

integritycare

Technical User
Mar 12, 2011
151
AU
Hi all again..
In our Document management system our documents are located on a server. If the user wants to hyperlink a new document they have to use the command, "Control K" to select the right folder, etc.

Is there a way that instead of using "Control K" that they can use the Double Click event on a textbox to hyperlink the documents.

Many thanks

Integrity
 
Are they already entering the full path, or is the full path always the same?

If it's always the same, then you could use any event to set it however you want. There's a few different ways to do it.

For instance, you could have your double-click event just go to the document rather than creating a hyperlink if you like. Here's an example for that:
Code:
Private Sub MyTextBox_DoubleClick()
  Dim strStaticPath As String
  Dim strFile As String
  strStaticPath = "C:\MySpecialFolder\"
  strFile = MyTextBox.Text
  Application.FollowHyperlink strStaticPath & strFile
End

That code is assuming that the full file name, including extension is included. If not, and it's always the same extension, you can include that in the code. If it is not always the same extension, and you're pretty positive that there will only be one file by that name, regardless of extension, then you could do a search for the file, basically, and find the extension... I believe there are a couple of different ways to do that.

If that's not what you're after, give us a little more to go on, and you can get a more accurate solution.
 
FollowHyperlink is certainly the way to go; imho...
However.. be careful with directory references. I use UNC Path References since some users may not have the same drive letter mappings.... htwh...

Steve Medvid
IT Consultant & Web Master
 
Hi kjv1611,

Many thanks for your reply. Sorry about this delay. Ive been in Dubai for the last two months with no computer access.
The Document form has a text box (Title). The process is that after generating a word document it is saved in the respective folder on the server. It then has to be hyperlinked from the form (on the local computer) to the server. At present after the document name has been typed in the user has to use the control K to link it to the server.
I have used your code but I get an error;
"Cannot open the specified file."

I modfied your code as follows:
Code:
  Dim strStaticPath As String
  Dim strFile As String
  strStaticPath = "C:\Test\"
  strFile = Title.Text
  Application.FollowHyperlink strStaticPath & strFile

Many thanks

Integrity


 
maybe Title.[red]Text[/red] change to Title.[blue]txt[/blue] [3eyes]

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work" <<Edison>>
 
Yup, what MazeWorX pointed out. You listed the type of file rather than the file extension... you always refer to files by their name.extension, not name.filetype. The extension tells the system what type of file it is, and therefore how to handle it.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top