Network browse Box


Posted by Simon McArdle on May 11, 2001 1:15 AM

I want to create a macro that allows me to browse the network for my file.

Is it possible to have a macro that when it runs it first opens the file open dialogue and waits for you to select your file....when file selected....it runs the rest of the macro.....ie...its waiting for user input.

Does this make sense.

Thanks
Simon

Posted by Ivan Moala on May 11, 2001 8:00 AM

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

Posted by Simon McArdle on May 11, 2001 10:12 AM

Thanks....Im going to try this out.

Simon

Posted by Simon McArdle on May 12, 2001 12:44 AM

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

Posted by Ivan Moala on May 12, 2001 1:43 AM

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

Posted by Simon McArdle on May 14, 2001 12:19 AM

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



Posted by Ivan Moala on May 14, 2001 5:35 AM

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