Working in Word 2010 VBA. using the method below to read from, and in this case, write to an Excel file using ADODB. I've used this method countless times with no problem. But tonight all of a sudden when I reaches the objRecSet.AddNew command, it gives me the error message "Cannot update. Database or object is read only." The Excel file is not read only, is not open in Excel, and was properly shut down by my last ADOBD routine.
What could be causing this?
Set objConnection = New ADODB.ConnectionobjConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DataFile & ";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=0"";" 'HDR=YES means has col headingsobjConnection.OpenSet objRecSet = New ADODB.RecordsetobjRecSet.Open TableName, objConnection, adOpenKeyset, adLockOptimistic For myrow = 0 To SaveSystem.ListBox3.ListCount - 1 objRecSet.AddNew objRecSet.Fields(0) = Me.TextBox1.Text For mycol = 0 To 4 objRecSet.Fields(mycol + 1) = SaveSystem.ListBox3.List(myrow, mycol) Next mycol Next myrowobjRecSet.UpdateBatchobjRecSet.CloseobjConnection.CloseSet objRecSet = NothingSet objConnection = Nothing
Microsoft ApplicationsMicrosoft ExcelMicrosoft Word
Last Comment
Bryce Bassett
8/22/2022 - Mon
x-men
"The Excel file is not read only, is not open in Excel, and was properly shut down by my last ADOBD routine. "...still, sounds like it is in use, some how. can you reboot?
Bryce Bassett
ASKER
I did reboot and the problem persists. Any other suggestions? Is my syntax otherwise in good shape?
This wasn't really an issue with the code itself, but the installation environment. Not fair to expect the experts to know what was going on with that.