Create a folder on share point through Excel VBA

%3CLINGO-SUB%20id%3D%22lingo-sub-200414%22%20slang%3D%22en-US%22%3ECreate%20a%20folder%20on%20share%20point%20through%20Excel%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-200414%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Guys%2C%20have%20you%20ever%20try%20create%20folder%20on%20share%20point%20through%20Excel%20VBA%3F%3C%2FP%3E%3CP%3EMy%20code%20worked%20in%20last%20month%2C%20however%20it%20is%20failed%20to%20work%20recent%20days%2C%20and%20the%20error%20type%26nbsp%3Bis%20run%20time%20error%20'76'%2C%20path%20not%20found%2C%20could%20anyone%26nbsp%3Bgive%20me%20some%20suggestions%3F%20Thanks%20a%20lot!!!!%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20code%20is%20like%20this%3A%3C%2FP%3E%3CP%3EDim%20fso%20As%20Scripting.FileSystemObject%3CBR%20%2F%3ESet%20fso%20%3D%20New%20Scripting.FileSystemObject%3C%2FP%3E%3CP%3E%26nbsp%3BDim%20strURL%20As%20String%3CBR%20%2F%3E%26nbsp%3BDim%20openURL%20As%20String%3CBR%20%2F%3E%26nbsp%3BstrURL%20%3D%20%22%5C%5Cxxx.sharepoint.com%5Cteams%5Cxxxx%5CShared%20Documents%5Cxxx%5Cxxxx%5C%22%3CBR%20%2F%3E%26nbsp%3BstrURL%20%3D%20strURL%20%26amp%3B%26nbsp%3Bfoldername%20%26amp%3B%20%22%5C%22%3CBR%20%2F%3E%26nbsp%3Bfso.CreateFolder%20(strURL)%3C%2FP%3E%3CP%3E%26nbsp%3BopenURL%20%3D%20Replace(strURL%2C%20%22%5C%22%2C%20%22%2F%22)%3CBR%20%2F%3E%26nbsp%3BActiveWorkbook.FollowHyperlink%20Address%3A%3D%22https%3A%22%20%26amp%3B%20openURL%2C%20NewWindow%3A%3DTrue%3CBR%20%2F%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-200793%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20folder%20on%20share%20point%20through%20Excel%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-200793%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20thanks%20for%20your%20reply.%20i%20tried%20this%20way%2C%20and%20run%20time%20error%2052%20bad%20file%20name%20occurred%2C%20at%20this%20sentence%20%3A%26nbsp%3BIf%20Dir(Fld_r%2C%20vbDirectory)%20Then%3C%2FP%3E%3CP%3EI%20googled%20and%20still%20didn't%20find%20the%20reason.%3C%2FP%3E%3CP%3EDo%20you%20have%20any%20ideas%3F%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-200599%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20folder%20on%20share%20point%20through%20Excel%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-200599%22%20slang%3D%22en-US%22%3E%3CP%3ECan%20you%20Please%20try%20below%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22typ%22%3EDim%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20strDate%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EAs%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EString%3C%2FSPAN%3E%0A%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EDim%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20strTime%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EAs%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EString%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20strDate%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EDate%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20strTime%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3ETime%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20strDate%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EFormat%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ENow%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22mmmdd%20yyyy%20hh%20mm%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EDim%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20strURL%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EAs%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EString%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%3CSPAN%20class%3D%22str%22%3E''%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ECopy%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Eand%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20paste%20the%20URL%20of%20your%20sharePoint%20folder%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22kwd%22%3Ewhere%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20you%20want%20to%20create%20another%20folder%0A%20%20%20%20%20%20%20strURL%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22http%3A%2F%2FYour%20URL%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20strURL%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EReplace%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EReplace%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EstrURL%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22http%3A%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22%2F%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22%5C%22)%0A%0A%0A%0A%20%20%20%20%20%20'%20MsgBox%20strDate%2C%20vbInformation%0A%20%20%20%20%20Dim%20Fld_r%20As%20String%0A%20%20%20%20%20Fld_r%20%3D%20strURL%20%26amp%3B%20strDate%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20MsgBox%20Fld_r%2C%20vbInformation%0A%20%20%20%20If%20Dir(Fld_r%2C%20vbDirectory)%20Then%0A%20%20%20%20MkDir%20(Fld_r)%0A%20%20%20%20DoEvents%0A%20%20%20%20End%20If%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Deleted
Not applicable

Hi Guys, have you ever try create folder on share point through Excel VBA?

My code worked in last month, however it is failed to work recent days, and the error type is run time error '76', path not found, could anyone give me some suggestions? Thanks a lot!!!! 

My code is like this:

Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject

 Dim strURL As String
 Dim openURL As String
 strURL = "\\xxx.sharepoint.com\teams\xxxx\Shared Documents\xxx\xxxx\"
 strURL = strURL & foldername & "\"
 fso.CreateFolder (strURL)

 openURL = Replace(strURL, "\", "/")
 ActiveWorkbook.FollowHyperlink Address:="https:" & openURL, NewWindow:=True
 

 

2 Replies
Highlighted

Can you Please try below

 

Dim strDate As String
     Dim strTime As String     strDate = Date     strTime = Time     strDate = Format(Now(), "mmmdd yyyy hh mm")
       Dim strURL As String
       ''Copy and paste the URL of your sharePoint folder where you want to create another folder
       strURL = "http://Your URL"       strURL = Replace(Replace(strURL, "http:", ""), "/", "\")



      ' MsgBox strDate, vbInformation
     Dim Fld_r As String
     Fld_r = strURL & strDate                
     MsgBox Fld_r, vbInformation
    If Dir(Fld_r, vbDirectory) Then
    MkDir (Fld_r)
    DoEvents
    End If

 

Highlighted

Hi thanks for your reply. i tried this way, and run time error 52 bad file name occurred, at this sentence : If Dir(Fld_r, vbDirectory) Then

I googled and still didn't find the reason.

Do you have any ideas?

Thanks.