MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to display file/ folder path in the Text Box

  Asked By: Thelma    Date: Nov 25    Category: MS Office    Views: 1210

I am writing a macro in excel in which I need to
select Notepad file from my documents folder.
Can some one please tell me how can I display the
whole path in the text box. I tried to look on
internet and study some hints but no luck.



4 Answers Found

Answer #1    Answered By: Kerry Wright     Answered On: Nov 25


Answer #2    Answered By: Miriam Green     Answered On: Nov 25

Can you elaborate on this one......

Answer #3    Answered By: Alberta Miller     Answered On: Nov 25

What Text Box are you attempting to display  the file  / folder  path within?

Perhaps you could share what you have so far.

Answer #4    Answered By: Debbie Reyes     Answered On: Nov 25

This code should get you the full path  of the selected file...

'browse for a file  name
Public Function getFolderPath()
getFolderPath = MsgBox("Selected File: " & BrowseForFile("Choose
a folder...", 3))
End Function

'this function returns a file name that the user selected
Public Function BrowseForFile(startFileName As String, fileFilterIndex
As Integer) As String
Dim selFile, oDlg

Set oDlg = CreateObject("UserAccounts.CommonDialog")
With oDlg
.Filter = "PowerPoint (*.ppt)|*.ppt|Excel (*.xls)|*.xls|All
Files (*.*)|*.*"
.FilterIndex = fileFilterIndex
.FileName = startFileName '"Leave as is for new sheetmask..."
'.flags = &H200 'this is for multiple files selection
'.InitialDir = "C:\temp"
selFile = .ShowOpen
End With
If selFile <> 0 Then _
BrowseForFile = oDlg.FileName
Set oDlg = Nothing
End Function

Didn't find what you were looking for? Find more on How to display file/ folder path in the Text Box Or get search suggestion and latest updates.