Capture File Path Name and Location on Cell

HotNumbers

Well-known Member
Joined
Feb 14, 2005
Messages
732
I need help on capturing the file Path and making it into a link to the source.

I have a Workbook were I import a sheet from an external workbook using VBA. I would like to be able to capture the path of the source and enter the file path into another cell with a link to the source. Hope I was clear, if not be happy to supply more info.

Here is the code i am using for importing:

Dim nName As Name
For Each nName In Names
If InStr(1, nName.RefersTo, "#REF!") > 0 Then
nName.Delete
End If
Next nName

On Error GoTo Error_Loader

Load:
NAME1 = Application.GetOpenFilename
Set NAME2 = ThisWorkbook

If NAME1 = False Then
ans = MsgBox("The load process has been canceled. " & vbNewLine & vbNewLine & _
"Click RETRY to restart the load process " & vbNewLine & _
"Click CANCEL to end the load process", vbRetryCancel, _
"Data")
If ans = vbRetry Then GoTo Load
If ans = vbCancel Then Exit Sub
End If

'''Data Report

Workbooks.Open Filename:=NAME1
Set Name3 = ActiveWorkbook
NM = ActiveWorkbook.Name
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
below line would add the hyperlink to source file:
Code:
ActiveSheet.Hyperlinks.Add ActiveSheet.Range("B2"), NAME1, , , "Source File"
change the range as per your need.
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top