I have an old macro that I used to use to separate a dataset onto specific tabs, and then save those individual tabs as their own file. These files were saved in a date/timestamped subfolder where ever the main file existed.
My issue is that I have now saved a version of this macro onto a SharePoint folder, and when I run it I get an error "Path not Found" and when i Debug, the line 'MkDir FolderName" is highlighted.
Can anyone explain what needs to be changed in order for this to work in a SharePoint folder?
Note: This file will be used by many individuals, so their specific SharePoint drive will have different 'paths'.
Here is the portion of the macro that I believe is the issue...
Any help is VERY apprecaited.
Sorry if I didn't post this correctly.
Set Sourcewb = ThisWorkbook
DateString = Format(Now, "yyyy-mm-dd hh-mm")
FolderName = Sourcewb.Path & "" & Sourcewb.Name & " " & DateString
MkDir FolderName
For Each sh In Sourcewb.Worksheets
If sh.Visible = -1 Then
sh.Copy
Set Destwb = ActiveWorkbook
With Destwb
If Val(Application.Version) < 12 Then
FileExtStr = ".xls": FileFormatNum = -4143
Else
If Sourcewb.Name = .Name Then
MsgBox "Your answer is NO in the security dialog"
GoTo GoToNextSheet
Else
Select Case Sourcewb.FileFormat
Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
Case 52:
If .HasVBProject Then
FileExtStr = ".xlsm": FileFormatNum = 52
Else
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Case 56: FileExtStr = ".xls": FileFormatNum = 56
Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
End Select
End If
End If
End With
If Destwb.Sheets(1).ProtectContents = False Then
With Destwb.Sheets(1).UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
End If
With Destwb
.SaveAs FolderName _
& "" & Destwb.Sheets(1).Name & FileExtStr, _
FileFormat:=FileFormatNum
.Close False
End With
Bookmarks