Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8613443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:52:37+00:00 2026-06-12T04:52:37+00:00

I need the path name and file name of the file that is opened

  • 0

I need the path name and file name of the file that is opened with File Dialog. I want to show this information with a hyperlink in my worksheet.

With this code I have the file path:

Sub GetFilePath()

Set myFile = Application.FileDialog(msoFileDialogOpen)
With myFile
    .Title = "Choose File"
    .AllowMultiSelect = False
    If .Show <> -1 Then
        Exit Sub
    End If
FileSelected = .SelectedItems(1)
End With

ActiveSheet.Range("A1") = FileSelected
End Sub

I’m still looking for a way to get the filename.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:52:38+00:00Added an answer on June 12, 2026 at 4:52 am

    Try this

    Sub Demo()
        Dim lngCount As Long
        Dim cl As Range
    
        Set cl = ActiveCell
        ' Open the file dialog
        With Application.FileDialog(msoFileDialogOpen)
            .AllowMultiSelect = True
            .Show
            ' Display paths of each file selected
            For lngCount = 1 To .SelectedItems.Count
                ' Add Hyperlinks
                cl.Worksheet.Hyperlinks.Add _
                    Anchor:=cl, Address:=.SelectedItems(lngCount), _
                    TextToDisplay:=.SelectedItems(lngCount)
                ' Add file name
                'cl.Offset(0, 1) = _
                '    Mid(.SelectedItems(lngCount), InStrRev(.SelectedItems(lngCount), "\") + 1)
                ' Add file as formula
                cl.Offset(0, 1).FormulaR1C1 = _
                     "=TRIM(RIGHT(SUBSTITUTE(RC[-1],""\"",REPT("" "",99)),99))"
    
    
                Set cl = cl.Offset(1, 0)
            Next lngCount
        End With
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to scan FAT32 disk (I just need file path and file name)
Fresh Asking of this Question-> I have a WIX file that I need to
I have a batch file that creates a scheduled task using schtasks like this:
I have the path name to a .exe file. How do I find the
I have an XML file that is constantly being appended to. I need to
I have some text configuration file that need to be read by my program.
I have a folder that contains multiple word documents. I need to monitor this
I need to get the full path of the file that I'm editing with
I need path to the folder that contains cmd file. With %0 I can
I need a batch file that prompts the user for a file path, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.