PDA

View Full Version : follow hyperlink to location then delete linked file



bobbuilder
01-07-2015, 04:11 PM
I have been trying with this for ages I have seen many post on deleting the link what I need to do is follow the hyperlink then delete the word file that it links to can anyone help please ?

Paul_Hossler
01-07-2015, 04:44 PM
I have been trying with this for ages I have seen many post on deleting the link what I need to do is follow the hyperlink then delete the word file that it links to can anyone help please ?

Where's the Word file located? On the computer that will run the macro?

Is the link on a worksheet or in the VBA?

Could be something like this, but I'd add error checking / catching / handling before putting it into production



Option Explicit
Sub DeleteFileInLink()
Dim rCell As Range
Dim sFile As String


'hyperlink inserted in worksheet
Set rCell = ActiveSheet.Range("A1")

On Error Resume Next
sFile = rCell.Hyperlinks(1).Address
Call Kill(sFile)
On Error GoTo 0
End Sub

bobbuilder
01-08-2015, 03:29 PM
the link is on the worksheet , the word file is on the computer the hyperlink in in column J and it should work for all those that say comp in column L