MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Thelma Murray   on Nov 25 In MS Office Category.

Question Answered By: Debbie Reyes   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



This Question has 3 more answer(s). View Complete Question Thread

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.