0

I have trouble saving WB that is opened as a read-only (from SharePoint server). Tried to add ReadOnly:=False to line that opens up the workbook, but vba still stopps and points to line wb_gr.Save. Is there a way to get around this? My code is located in a "master-dash" (same folder), that updates itself first, then opens next Dash, updates, saves and closes. And so on... When opening "master-dash", I click and remove all warnings = it updates and saves ok.

Sub UpdateDash()

Dim fPath As String
Dim wb_gr As Workbook

        fPath = ThisWorkbook.Path
        If Right(fPath, 1) = "\" Then
        fPath = Left(fPath, Len(fPath) - 1)
        End If

Set wb_gr = Workbooks.Open(ThisWorkbook.Path & "\dashboard.xlsm", ReadOnly:=False, Notify:=False)  

'(lot of updating going on - works just fine)

wb_gr.Save           '(Run-time error 1004. No access to file C:\windows\system32\CC90FF60)
wb_gr.Close False
    
End Sub
kit99
  • 187
  • 1
  • 3
  • 15
  • 1
    Did you really put your workbook in `C:\windows\system32`? why? – braX Jan 08 '22 at 09:00
  • No, I have not. All files is located in SharePoint, like this: `https://myjob.sharepoint.com/sites/FAG/PlanAndUpdates/2021/Dash/` I have no idea why error code is refering as it does. – kit99 Jan 08 '22 at 09:10
  • Why not save.as then copy it to the original location. – Solar Mike Jan 08 '22 at 09:55
  • What is the *actual value* of `ThisWorkbook.Path` (you should obscure the actual domain/folder/file names, but don't "simplify" the components) ? – Tim Williams Jan 08 '22 at 17:37
  • Basic question: Do you have write privileges on these files the normal way of editing Excel? I know our SharePoint sites have access rights where I have superpowers on some sites, and read-only access on others. Also, for the files I modify with VBA, I have to use an odd format of URL, like `\\mycompany.shpt.com@SSL\DavWWWRoot\sites\mShare\Shared Documents\myFile.xlsx`. [See here](https://stackoverflow.com/questions/21706142/what-is-davwwwroot) – ScottyJ Jan 10 '22 at 00:56
  • Relevant "basic question".. :-) I just sent a request til the IT-people at my job. – kit99 Jan 10 '22 at 12:43

0 Answers0