Double click set file path to a cell and include as hyperlink

drop05

Active Member
Joined
Mar 23, 2021
Messages
285
Office Version
  1. 365
Platform
  1. Windows
Hello, i have the below code where i am trying to double click a cell to open and browse and select a file, the file path will be pasted one cell to the right of the cell double clicking but it is not coming in as a hyper link or the correct hyper link

VBA Code:
Option Explicit


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Dim strFileToOpen As Variant

If Not Application.Intersect(Target, Range("config_FileBrowse")) Is Nothing Then
        Cancel = True

    Dim strSelectedFile As Variant
    Dim Default_Browse_Address As String
    
    Default_Browse_Address = Range("var_FileBrowse_DefaultAddress").Value
    
    With Application.FileDialog(msoFileDialogFilePicker)
        .Filters.Clear
        .Filters.Add "Excel Files", "*.csv, .xls, .xlsx", 1
        .Title = "Choose an Excel file"
        .AllowMultiSelect = False
    
        .InitialFileName = Default_Browse_Address
    
        If .Show <> False Then
            strSelectedFile = .SelectedItems(1)
            ActiveCell.Offset(rowOffset:=0, columnOffset:=1).Value = strSelectedFile
        End If
        
    End With

End If

End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I have to go out and am out of time but can suggest a method that worked for me. Try changing
ActiveCell.Offset(rowOffset:=0, columnOffset:=1).Value = strSelectedFile
to something like
ActiveSheet.Hyperlinks.Add Range("m" & i), Address:="", SubAddress:=Range("M" & i).Address, TextToDisplay:="custom text here if needed"
Change the range reference to your cell offset and the address to strSelectedFile
Gotta run.
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,121
Members
452,381
Latest member
Nova88

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