index > Visual Basic for Applications (VBA) > hyperlinks don't work when pointing to file shortcuts

hyperlinks don't work when pointing to file shortcuts


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

MDY

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




Access/SQL Developer
Tracey Hughes

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

MDY

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.




www.dsmyth.net/blog
Derek Smyth
reply 4

You can use google to search for other answers

 

More Articles

• VBA w/ Word 2000 - keep form on top of all applications
• Resolving ShellLinks in VBA
• Linking to an Oracle DB via MSAccess/VBA
• Wierd error I cannot figure out
• autocomplete
• VBA Excel - Using FindNext function
• Opening a Word Document from an Excel VBA Module
• VBA Harddisk serial
• Word 2000 section page numbering bug? Any workaround?
• Problem with Defined names
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• Can i embed MS Access database inside Vi
• Excel: Treeview handle events for dynami
• excel vba
• Activate a workbook based on a value in
• Copy Paste (VBA)
• Problem Programmatically adding treeview
• hidden versus visible in pivot tables
• Coordinate of the mouse pointer in chart
• How do connect an Excel file from Remote
• VBA WORKSHEET
• Increase Speed of a Word Macro
• adding a routine/event to a control duri
• Help !!!
• custom toolbar error
• CDONTS

Hot Articles

• VBA forms for Excel. Always on top ??
• Issues with Updating Sharepoint List...
• Initialize Sub routine
• Table Caption Property
• access - importing specific data from ex
• Programatically Changing Excel Default D
• How can I determine if a character is nu
• Migrate Access Forms with VBA to VB.NET
• Error refencing DLL in XLA
• how to read merged cells?
• How to refer to an object by the tab index
• Newbie Help: All caps to Title caps
• Problem with Applying Filter in MS Proje
• Acces1 1.0 converted to Acces 2003 but t
• print out to .pdf or calling a macro wit

Recommend Articles

• [Excel] How to convert Excel to jpg, gif
• Number formatting
• Copy...Paste...by Macro!
• Help with Run-time error 1004
• Run-time error '1004' in import macro
• DoCmd (1312)
• Visio Zoom
• Missing values
• Detecting Excel Password
• so lost and buried in help printouts
• Using user form to create list of files
• Bounded frame object... how to activate
• How do you find out the Windows User Nam
• Office XP VBA can't find reference after
• For Each & Variable Problem