Click to See Complete Forum and Search --> : [RESOLVED] I need to open, edit and save an excel worksheet


Funkymonkey
04-12-2006, 10:40 AM
I've got my connection and can update the excel sheet from my webpage fine. Later on in the code I look up some updated cells from the sheet and display these in a label on my webpage. What I need to do is to save the spreadsheet after I update it (because it brings up old info otherwise). Here's my code:

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=ExcelTest.xls; Extended Properties=""Excel 8.0;"""


Dim cmd As New OleDbCommand("UPDATE [old$] SET Col1 = '" & timenow & "' WHERE Col2 = 'a'", strConn1)
Dim DACurrent As New OleDbDataAdapter("Select * from [old$B3:B3]", strConn)
Dim DANext As New OleDbDataAdapter("Select * from [old$B4:B4]", strConn)

DACurrent.Fill(DSCurrent)
DANext.Fill(DSNext)

First = DSCurrent.Tables(0).Columns(0).ColumnName
Second = DSNext.Tables(0).Columns(0).ColumnName

So when I update the sheet (at col 1), cells B3 and B4 get updated (as the formulas in these cells reference the one I just updated) and I then read these cells. How do I save the spreadsheet after the update and before I read these two cells???

Thanks loads!

Funkymonkey
04-13-2006, 04:24 AM
Ok I have it working but how do I get it not to ask if I want to save over the original file with the same name?