I tried to use the code I found https://sharepoint.stackexchange.com/questions/174690/open-file-in-a-sharepoint-list-via-vba
My goal is to save the document in the users temp folder and then open it. However I am getting
error 52
on the FileCopy line. I copied the sharepoint link directly off of the email link so it should be exactly accurate.
I referred to many questions on here regarding FileCopy Error 52, but was unable to find a relevant answer.
If it is possible to open the document without saving that would actually be preferable, but I cannot use the Microsoft Scripting Runtime as some individuals are on Macintosh computers that do not have that library. The solutions I found that were a straight open seemed to all require that which is why I am saving and then opening.
Dim strFolder As String
Dim strName As String
Dim URL As String
strFolder = Environ("temp")
strName = "\QpiExport.xlsx"
URL = "https://sharepoint.company.com/some/more/files/Shared%20Documents/QSPI%20Export/QpiExport.xlsx"
If Dir(strFolder & strName) <> "" Then ' if the temp file already exists then delete it first
VBA.SetAttr strFolder & strName, vbNormal ' remove any file attributes (e.g. read-only) that would block the kill command
VBA.Kill strFolder & strName ' delete the file
End If
FileCopy URL, strFolder & strName
Workbooks.Open strFolder & strName
Environ("temp"), is it what it should be? I.e. a valid path that you can append a filename to? - Andy G