vba Create Folder on SharePoint

katekoz

Board Regular
Joined
Jan 20, 2020
Messages
91
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have a macro that needs to create a folder on SharePoint, then generate and save multiple files under that folder. I've done a lot of work to get the code right for creating the folder, but with no success. I've read that you need to drop the http: from the front of the folder address, change all of the / to \ and change any %20 to space. I've done all those things and still get the error "Run-time error '75': Path/File access error."

I do have permission to create a folder on the SharePoint site and tested that by actually creating one. I can also Open in Explorer and create a folder that way.

Below is the code I'm using to create the folder (with the filepath changed). The macro continues on after what's posted to create the files within that folder.

VBA Code:
Sub PDF_User_Graphs()
'

Dim ws As Worksheet
Dim sourcesheet As Worksheet
Dim strDirname As String
Dim strPathname As String
Dim strDefpath As String

Set sourcesheet = ActiveSheet

Application.ScreenUpdating = False


'Create new month folder

strDirname = Format(Sheets("Inputs").Range("B2"), " yyyy-MMM") ' New folder name

MkDir "\\my.sharepoint.website\sites\departments\test\Test\Test Test\Test Test" & strDirname
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Katekoz, What did you do to solve this? I am looking for a solution to create a new folder via VBA direct in sharepoint. I have tried various options but no luck to find a workable solution via google.
Anyone who can help me?
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,638
Members
449,093
Latest member
Ahmad123098

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top