Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Dialog

Status
Not open for further replies.

sanjna000

Programmer
Aug 1, 2003
132
GB
I used below code to use open dialog

Application.GetOpenFilename ("Microsoft Excel Files (*.xls),*.xls")

But i don't know how to display the file name in the open dialog box when selecting particular excel file.

Any suggestions?

Thanks,
Sanjna...
 
Depending of your version of excel you may consider the Application.GetSaveAsFilename method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
You could pass the File name to a variable.
Then make the dialog box = the variable.
You need to have TextBox1 somewhere on the form. I created a "browse" button and attached this sub to the button click event. This lets you capture the file name for use later in your application. After this you can call a sub with the Open dialog in it to actually open a file. The drawback is that I have never been able to assign a default path this way in office 2k and always have to browse from My Computer.

Private Sub GetFilename()
'This Initiates the Browse Window
Application.DefaultFilePath = ("C:\Test")
FN = Application.GetOpenFilename(FileFilter:="(Excel Workbooks(*.xls),*.xls", Title:="Open File")

If FN <> False Then
'Display the Full Path in the Text Box'
TextBox1_Change

ElseIf FN <> True Then
MsgBox "No File Selected"
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top