Solved

Hyperlinks - when they go bad?

Posted on 2014-02-06
7
186 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 400 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for that. Got me thinking in a whole different way..much appreciated.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
glad I could help.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

My experience with Windows 10 over a one year period and suggestions for smooth operation
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

763 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

6 Experts available now in Live!

Get 1:1 Help Now