Solved

Hyperlinks - when they go bad?

Posted on 2014-02-06
7
197 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

856 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