Simon
Sub TestFileName()
Dim FileNm As String
Dim Temp As String
Dim x As Integer
FileNm = Application.GetOpenFilename
If FileNm = "False" Then End
'Use this to get File name only
x = 1
While InStr(x, FileNm, "\") <> 0
Temp = InStr(x, FileNm, "\")
x = x + 1
Wend
FileNm = Right(FileNm, Len(FileNm) - x + 1)
MsgBox FileNm
'The rest of your macro
End Sub
OR to get the full path of the file;
Sub TestFileName1()
Dim FileNm As String
Dim Temp As String
Dim x As Integer
FileNm = Application.GetOpenFilename
If FileNm = "False" Then End
'Use this to get File name only
MsgBox FileNm
'The rest of your macro
End Sub
Ivan
Thanks....Im going to try this out.
Simon
Hi Ivan,
This works great at opening the network browse. When I select the file though it does not open it. Am I doing something wrong here.
Thanks
Simon
Simon
I assumed you had your code you wanted to run.
If you wish to open the selected file then use this mod;
Sub TestFileName1()
Dim FileNm As String
Dim Temp As String
Dim x As Integer
FileNm = Application.GetOpenFilename
If FileNm = "False" Then End
Workbooks.Open FileNm
End Sub
Ivan
Thanks Ivan that works great. How do I get the search box to default to a specific directory....ie c:\my documents. Thanks for your help
Simon
Sub TestFileName1()
Dim FileNm As String
Dim Temp As String
Dim x As Integer
ChDrive "C:\"
ChDir "C:\My Documents"
FileNm = Application.GetOpenFilename
If FileNm = "False" Then End
'The rest of your macro
Workbooks.Open FileNm
End Sub
Ivan