• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

hyperlink in excel to open file location and select the file but not open it

dear all,
I want a hyperlink in excel to a file which will open the file location and select the file but not open it.
After doing some searching on google I am able to achieve this using---------------- explorer.exe /select,"C:\Folder\subfolder\file.txt" .
But here I have to paste this on file explorer .
I want to achieve this using hyperlink so that when I can click on it I can get to the the file location with the file selected.

Regards
 
Code:
Option Explicit

Sub File_Exists()
    Dim FileName As String
    'Update the path to a valid path on your PC
    FileName = VBA.FileSystem.Dir("C:\Users\gagli\Desktop\MakSubScript.xlsm")
    If FileName = VBA.Constants.vbNullString Then
        MsgBox "file does not exist."
    Else
        'Update the path to a valid path on your PC
        'Workbooks.Open "C:\Users\gagli\Desktop\" & FileName
        MsgBox "File exists"
        
    End If
End Sub
 
Back
Top