Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15537

User wants to changes the selected file in openfiledialog

$
0
0
Hello guys i'm trying to make a code that asks the user to choose a file dialog then download its worksheets into a combobox. the problem is that if the user didn't choose the right file dialog and wants to choose an other one the file chosen becomes read only since it wasn't closed proparly can you suggest me how to change this code. thank you sooo much

Code:


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
        ComboBox1.ResetText()
        ComboBox1.Items.Clear()
            TextBox1.Text = OpenFileDialog1.FileName
            xlworkbook = xlApp.Workbooks.Open(TextBox1.Text)

            For Each xlWorkSheet In xlApp.Sheets
                ComboBox1.Items.Add(xlWorkSheet.Name)
            Next
        end if
end sub


Viewing all articles
Browse latest Browse all 15537

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>