Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Browse Excel File to get its path in windows application?
Posted

1 solution

Hi..
VB
Private Sub btnbrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbrowse.Click
        Try
            Dim dlg As New OpenFileDialog
            dlg.InitialDirectory = Application.StartupPath
            'dlg.InitialDirectory = "C:\Program Files\Default Company Name\ePolitices"
            dlg.Filter = " (*.xlsx)|*.xlsx" 'Microsoft Excel File "
            dlg.FilterIndex = 1

            If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
                txtname.Text = dlg.FileName

            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub


I hope this will help you....
 
Share this answer
 
Comments
[no name] 6-Mar-14 5:01am    
It works. Thank you.
One question if I browse then click browse again is there a way to make it point to the same folder I picked it from the last time I browsed?
basurajkumbhar 6-Mar-14 5:36am    
dlg.InitialDirectory =""
here you can set where you want to get excel file.
Like
dlg.InitialDirectory="c:\"
[no name] 6-Mar-14 5:04am    
The filter for xls or xlsx Missing )?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900