Forum Discussion

Anonymous's avatar
Anonymous
Jun 04, 2018

Create a folder on share point through Excel VBA

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

  • Anonymous's avatar
    Anonymous

    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

     

    • Anonymous's avatar
      Anonymous

      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.

       

Resources