I want to run the below VBA
to create a new folder within the folder where the current file is stored.
So far I have done this using the following simple VBA
:
Sub Create_Folder()
MkDir Application.ThisWorkbook.Path & "\New Folder"
End Sub
Now, my company moved to sharepoint and when I run this VBA
within a sharepoint folder I get runtime error 76
.
I assume this is caused because ThisWorkbook.Path
can not correctly identify the path anymore.
Therefore, I checked how the path looks like:
https://company.sharepoint.com/sites/Finance1/Freigegebene Dokumente/Controlling/
In order to use this path I adjusted it in the VBA
:
Sub Create_Folder()
WorkbookPath = ThisWorkbook.Path
WorkbookPath = "\\" & Replace(Split(WorkbookPath, "//")(1), "/", "\")
MkDir WorkbookPath & "\New Folder"
End Sub
However, I am still getting runtime error 76
when I try to create the new folder.
What is strange to me is that when I check the link in the windows explorer
it loosk totally different to the link that I get with Application.ThisWorkbook.Path
.
C:\Users\firstname.lastname\company\Controlling - Dokumente
Do you have any idea how I can solve this issue and create a new folder in the same folder where the current file is stored?