I am trying to use the code below to save Workbook files that are created from individual sheets in a secondary workbook into my department's SharePoint, but the files are not showing up after the macro has run. There are no errors showing up and when I tried running this macro in a folder on my desktop it saved all the files correctly. Any ideas as to why it just won't work when its in a SharePoint?
Sub SaveShtsAsBook()
Dim Sheet As Worksheet, SheetName$, MyFilePath$, N&
Dim theFilePath As String
MyFilePath$ = ActiveWorkbook.Path & "\"
For Each Sheet In ThisWorkbook.Worksheets
SheetName$ = Sheet.Name
With Application
.ScreenUpdating = False
.DisplayAlerts = False
' End With
On Error Resume Next '<< a folder exists
theFilePath = MyFilePath & "FY 20-21 P Card Statements - " & SheetName
MkDir theFilePath
theFilePath = theFilePath & "/" & "February Statement 1.6.21-2.6.21"
MkDir theFilePath
With Sheet
.Select
.Copy
ActiveWorkbook.SaveAs Filename:=theFilePath & "/" & SheetName & " Feb-06.xlsx", FileFormat _
:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close
End With
.CutCopyMode = False
End With
Next Sheet
End Sub