Pat_The_Bat
Board Regular
- Joined
- Jul 12, 2018
- Messages
- 83
I have a macro that creates a folder for every new client we engage with a specific folder structure. It copies a template folder to the desired location, then renames the folder based on the input in the excel workbook I run that macro from.
Sometimes when I open the template, it has an active path of:
https://companyname.sharepoint.com/sites/Team555/Shared Documents
and this causes the macro to bug...
Sometimes the same file opened from the same location has an address of:
C:\Users\myname\company name\Team Shared Documents
Works fine when it has this C local address.
Any help would be greatly appreciated.
Sometimes when I open the template, it has an active path of:
https://companyname.sharepoint.com/sites/Team555/Shared Documents
and this causes the macro to bug...
Sometimes the same file opened from the same location has an address of:
C:\Users\myname\company name\Team Shared Documents
Works fine when it has this C local address.
Code:
Sub CreateWinfile()
Dim fsoFSO
Dim bornm As String
Dim path As String
path = Application.ActiveWorkbook.path
path2 = path & "\Brunner - In Process\"
MsgBox (path)
path = Application.ActiveWorkbook.path
Debug.Print path
With Sheets("Cover")
bornm = Range("L5").Value
End With
Debug.Print bornm
Set fsoFSO = CreateObject("Scripting.FileSystemObject")
If fsoFSO.FolderExists(path2 & bornm) Then
MsgBox "The WinFile " & bornm & " already exists"
GoTo Ending
Else
'On Error GoTo user2
Set fsoFSO = CreateObject("Scripting.FileSystemObject")
fsoFSO.CopyFolder path & "\CLIENT WORKBOOK\Z folder Template DO NOT ERASE\ZZZ Template", path2, True
Dim FileName As String
Dim NewFileName As String
On Error Resume Next
FileName = path2 & "\ZZZ Template"
NewFileName = path2 & bornm
Any help would be greatly appreciated.