"Cannot update. Database or object is read-only." error when file on OneDrive

masouder

Board Regular
Joined
Jul 5, 2013
Messages
111
Office Version
  1. 2013
Platform
  1. Windows
I wrote a function to create a database connection that has worked well for years. A client recently moved the file that contains the function to OneDrive and now they receive the error in the subject line. Any ideas on how to resolve? Note that I tried to include the IMEX=1, as suggested by another post, but this just produced a different error.

VBA Code:
Function ConnectToSpreadsheet(CurBook As Workbook, conn As Connection)
    ConnectToSpreadsheet = True
    
    On Error Resume Next
    
    'Create the ADODB connection object
    Set conn = New ADODB.Connection

    'Open connection
    conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & _
            CurBook.FullName & "';Extended Properties='Excel 8.0;HDR=Yes'" ';IMEX=1'"
    
    conn.Open
    
    If Err.Number <> 0 Then
        MsgBox "Could not connect to spreadsheet", vbOKOnly, "Connect To Spreadsheet"
        Set conn = Nothing
        ConnectToSpreadsheet = False
    End If

End Function
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
What is curbook value?
If it is a file on OneDrive change it to the files local copy (hopefully files are synced to a local folder and OneDrive app is installed) - there are discussions about this on this board.
Why do you pass conn as a parameter and then create a new connection?
 
Upvote 0
Thanks for the reply. I'm not sure about a local copy, but I will look into that. Can you refer me to specific discussions on this topic? I could not find anything.
 
Upvote 0
I confirmed that it is a local copy from OneDrive. Does anyone have any ideas?
 
Upvote 0
Despite the fact that this is a local file, since it is synced with onedrive will return the online location of the file.
And there is no direct method to find the local path.
So the workaround is to locate the the file with Curbook.Name in your local OneDrive folder.
There is a discussion on the subject HERE. In the thread there are several more links which may also help.
 
Upvote 0
Thanks for the reply. Unfortunately, the link did not work. Can you confirm it?
 
Upvote 0
@masouder, click on the Search icon in the green header bar (top right corner of your browser screen), enter "onedrive" and multiple MrExcel topics regarding OneDrive issues will be displayed.
 
Upvote 0
I tried that but found nothing that I thought was on point or that helped. If anyone can refer me to any specific threads I would appreciate it.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top