Solved

Hyperlinks - when they go bad?

Posted on 2014-02-06
7
190 Views
Last Modified: 2014-02-10
Basically I have two questions here:

sometimes my hyperlinks just stop working (haven't moved the files) - they just get a load of gobbledegook in them e.g. &&%% etc. Should I just recreate them? This is in Excel

If I have a hyperlink to files in a folder eg. Access and the folder is moved - is there any way to ensure the hyperlink moves with it...or do I have to recreate the links again. Thank you
0
Comment
Question by:agwalsh
  • 4
  • 2
7 Comments
 
LVL 6

Assisted Solution

by:Aditya Arora
Aditya Arora earned 100 total points
ID: 39838387
Hi,

question 2 you need to recreate link again.

thanks Aditya
0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 400 total points
ID: 39838461
This is one of the reasons I don't use the hyperlink datatype in Access.  I generally save the filename and the filepath in separate fields in my Access database.  Then, I run a query that contatenates the two and validates whether the file still exists on that path, something like:

SELECT [FilePath] & [FileName] as FileFull, IsValidFile([FilePath] & [FileName])
FROM yourTable
WHERE [FilePath] & [FileName] is NOT NULL

Then function IsValidFile simply tests whether the file exists using the Dir() function:

Public Function IsValidFile(FullName as string)

    IsValidFile = (Len(Dir(FullName)) > 0)

End Function

Then you can present those files where the [FilePath]&[FileName] is not valid and allow the user to search along a different path, or select a different path and assign all files that were in the original path to the new path.
0
 

Author Comment

by:agwalsh
ID: 39838483
Hm, thanks for that. The scenario is that every year the IT people in the company do a "tidy up" which means they ask people to move folders etc..
So assuming the second step you mentioned there.." assign all files that were in the original path to the new path."...how would that be done? The users I am helping are not VBA savvy...so it would have to be very clear :-)
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 400 total points
ID: 39838512
I would actually probably build that "archiving" into the application.

1.  Create a form with a dropdown containing all of the distinct paths to which files are located.  This way they can select all of the records that are on that path.

RowSource = "SELECT DISTINCT [FilePath] FROM yourTable"

2.  Add a textbox for the new path.  You can use the filedialog object (search it here on EE) to get sample code for selecting the path (if you don't want them to type it in).

3.  Move button, would look to see whether the new path already exists.  If not, it would confirm you want to create it.  Then create a recordset containing all of the files that need to be moved to the new path (based on the [FilePath] value.  Loop through that recordset using the FileCopy statement to copy files from the oldpath to the new path.

4.  Before deleting the files from the current path, I would probably make another pass through that loop, making sure that all of the files were copied properly, and if so, would then update the [FilePath] for each file and delete the file from the existing path using the Kill statement.
0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 400 total points
ID: 39838516
Forgot about that, but you could also use the Name statement to do that all in one operation.

Name [OldFilePathAndName], [NewFilePathAndName]

which would eliminate step #4.
0
 

Author Closing Comment

by:agwalsh
ID: 39846774
Thanks for that. Got me thinking in a whole different way..much appreciated.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39846932
glad I could help.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
My experience with Windows 10 over a one year period and suggestions for smooth operation
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now