PDA

View Full Version : [SOLVED] Open path given in txtbox1



ilyaskazi
05-28-2005, 06:09 AM
Object: 2 txtboxes, 2 Directory Open button (Browse button)

In my Userform, near txtbox1, opnBtn1 is kept and likewise to txtbox2.

When I browse the path for excel file by clicking opnBtn1, the path and file name is stored in txtbox1 and likewise to txtbox2.

this is the code...


Private Sub opnBtn1_Click()
Dim File1name
File1name = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If File1name <> False Then
Me.txtbox1.Text = File1name
End If
End Sub


...but i dont want like this to happen with txtbox2, while browsing upon clicking opnBtn2.

I don't need to search again for selecting next file by clicking opnBtn2. I need, upon clicking this button, it should automatically locate the path from the txtbox1 to open any next file for txtbox2. Also vice versa upon clicking opnBtn1, get the location from txtbox2, if the value is not null.

MWE
05-28-2005, 05:28 PM
I found your problem/question quite difficult to follow. Please try to explain this again

ilyaskazi
05-30-2005, 08:21 PM
In short, if I click any opnbtn1 or opnbtn2 the browser must be open in the desired location where I wanted (for eg: c:\my folder) to open my excel file from this given location

ilyaskazi
06-01-2005, 06:19 AM
Actually I miss something to tell that upon loading my form, file location and file name of activeWorkbook is automatically detected for txtbox-1.

however, i hv attached my sample file here...

ilyaskazi
06-02-2005, 12:22 AM
or, is it possible to open browser window to open file in my desired folder??

help me somebody if possible....

ilyaskazi
06-02-2005, 05:36 AM
ok someone has solved for me as given below, which helped me out solving as per my requirement...



Sub Open_Folder()
Dim MyPath As String
Dim SaveDriveDir As String
Dim FName As Variant
SaveDriveDir = CurDir
MyPath = "C:\my project\new"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),*.xls",MultiSelect:=False)
'Do whatever you need to do with file....
ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub