Hi guys I'm having a problem in opening excel files using the workbook.open for me to save all the changes made by oledbcommands.
Dim MyConnection As New OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; Data Source='" & path & "'; Extended Properties=Excel 12.0;")
MyConnection.Open()
Dim i = 0
Dim h = Label1.Text
Do
'Dim q = DataGridView1.Rows(i).Cells(0).Value.ToString
Dim r = DataGridView1.Rows(i).Cells(2).Value.ToString
Dim bc = DataGridView1.Rows(i).Cells(1).Value.ToString
sql = "Update [" & ComboBox1.Text & "$] Set Designation = '" & r & "' Where F2 = '" & bc & "'"
Dim updt As OleDbCommand = New OleDbCommand(sql, MyConnection)
updt.ExecuteNonQuery()
i = i + 1
Loop While (i < h)
MyConnection.Close()
xlWorkBook = xlApp.Workbooks.Open(path)
xlWorkBook.Save()
xlWorkBook.Close()
I just recycled it from my other project. The error it shows is this: Excel cannot open the file 'Incentive Template.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file. I even test my previous project(which is also an excel file) and it's still working. I even tried to make a new one and still no luck. Is there any solution to this? I'm stuck.