hi guys
heres the problem i have a excell file which reads into a datagrid now everything works fine BUT yes theres alwas a but i want to password the excell file and have the password passed through to excell so far i have pulled out my hair teeth and now onto my toe nails any help would be brill thanks code attached


'TODO: This line of code loads data into the 'PhonedetailsDataSet.site' table. You can move, or remove it, as needed.
Me.SiteTableAdapter.Fill(Me.PhonedetailsDataSet.site)

Try
            Dim MyConnection As System.Data.OleDb.OleDbConnection
            Dim DtSet As System.Data.DataSet
            Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
            MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Users\stephen\Documents\phonelog.xls;Extended Properties=""Excel 8.0;HDR=YES;""")
            MyCommand = New System.Data.OleDb.OleDbDataAdapter _
                ("select * from [Sheet1$]", MyConnection)

            DtSet = New System.Data.DataSet

            MyCommand.Fill(DtSet)
            DataGridView1.DataSource = DtSet.Tables(0)
            MyConnection.Close()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

As far as I know it is impossible to use a driver to open a password protected Excel file. You have to use COM/Excel automation to access the data.

The behavior is documented for ODBC but as far as I know OleDb is the same: http://support.microsoft.com/default.aspx?scid=kb;EN-US;211378

That also is old but I haven't had luck with it. I gave up on password protected Excel files years ago.

I hope for your sake I am wrong :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.