'Sharepoint Locking Error when xlsm is Uploaded via VBA .SaveAs
I have this awesome vba macro that takes a template xlsm file saved on a shared drive and automatically uploads the file saved as with tomorrows date in the title to SharePoint. It is triggered by a specific appointment reminder out of outlook.
My issue is that although the file is being correctly saved to the SharePoint library, it seem to be locked for any kind of editing. I have done some research and I cannot seem to find a solution.
Error when trying to edit the file in browser: Can't Lock File for Editing Close Error We're sorry. We couldn't lock this file for editing. Would you like to try again?
Error when trying to edit properties in browser: The file "http://sharepoint/TESTING FILE.xlsm" is locked for exclusive use by i:0#.w|"MyuserID".
Not sure if there is some line I can add to the .SaveAs part in the VBA code or if there is some workaround.
My automation of this save as process is rendered useless if nobody can access/ edit the file on SP.
Sub savetest()
Dim Template As Workbook
Workbooks.Open ("C:\MyFilePath\Name")
Set Template = Workbooks("Name.xlsm")
Template.SaveAs FileName:= _
"http://sharepoint/MyLibrary/MyFilePath/Name" &
Format(WorksheetFunction.WorkDay(Date, 1), "MM-DD-
YYYY") & ".xlsm?web=1" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled,
CreateBackup:=False
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|