hyperlinks don't work when pointing to file shortcuts  
Author Message
MDY





PostPosted: Visual Basic for Applications (VBA), hyperlinks don't work when pointing to file shortcuts Top

Y'all--

I am using Access 2002 and creating an application that converts large sections of a user's file directory structure into tables of hyperlinks for querying and analysis. To do this, I have invoked the FileSystemObject and used GetFile and GetFolder in a recursive function that 'crawls' over the directory - grabbing 'Path' and 'Name' attributes and concatenating them with a hyperlink '#' separator. If a user clicks on the link in a form, backed by the resulting table, it follows effectively to the target file/resource, regardless of type.

But(!) if the links are then followed from code using the object.hyperlink.follow method, everything works as expected when a link is a regular file or a URL...but when a file shortcut has been copied into a table's hyperlink field it totally fails...and in a very strange fashion! Sometimes it does nothing, sometimes it pulls the directory where the shortcut is stored, rather than the 'target' file of the shortcut. When I query the text property of the control bound to the hyperlink field it shows a zero-length string! This is a very unhappy function, clearly.

Sadly, the solution of just storing the target of the alias to begin with, replacing the shortcut with a hyperlink address style that is known to work, seems quite hard to do. I am unable to find a way of getting at that information from the FileSystemObject or from an equivalent API. Also, I have tried 'simulating' the click event, in order to 'steal' its effective translation of the '.lnk' into the target file...but that has proven completely opaque as well...

This is VERY frustrating...the documentation of these matters is not particularly available or detailed...Any ideas are welcome - Thank you!

--Matthue



Microsoft ISV Community Center Forums1  
 
 
Tracey Hughes





PostPosted: Visual Basic for Applications (VBA), hyperlinks don't work when pointing to file shortcuts Top

Hi Matthue-

I found your post becuase I am researching doing the exact same thing! Your's is the only article I have found on the subject. It is very disappointing the hear that your hyperlinks won't work when you copy them into the table. A stupid que, but is the field of hyperlink type that you are copying into Did you have any luck since this post Anything you have come up with would be helpful to me before I start going down this same path.

Thanks,

Tracey



 
 
Derek Smyth





PostPosted: Visual Basic for Applications (VBA), hyperlinks don't work when pointing to file shortcuts Top

Hello,

I've had a look at this problem and it is a bit of a pain. It looks like the hyperlink field has a number of different formats, there's the "#http://www.yahoo.com#" format, and it also looks like there is a "filename.doc#file://C:\filename.doc#" format. Neither of these formats are valid for the hyperlink.follow method which doesn't like # delimiters or the inital filename.

When you remove the # # delimiters and, for the second format, the inital 'filename.doc' then the follow works fine... even with a shortcut lnk. Looks like a bit a string formatting is in order.

I hope that proves helpful.



 
 
MDY





PostPosted: Visual Basic for Applications (VBA), hyperlinks don't work when pointing to file shortcuts Top

Hey fellow-traveler--

Good news...everything I am doing works now...Bad news...I don't understand what I am doing differently. Even some of the example apps that I was feature testing on are working, when they bugged before. There is probably some incredibly subtle thing going on here that I would like to master so that things don't suddenly stop working in the future -- but...ANYWAY!!!---

1) Go right ahead and use the FileSystemObject to talk to the directories, pulling the paths and filenames;

2) Concatenate these two strings with a '#' separator so that it matches hypertext protocol;

3) Dump the new string into a hypertext field;

4) Use the Control.Hyperlink.Follow method from code to simulate a click-through on a bound control using the field in 3);

This will launch local files, including shortcuts, and URL's...I will post another message if I figure out why this functionality sometimes decides to take a vacation!

Let me know if you have any other questions regarding this kind of application...it is a very interesting area of computing!!!

--Matthue