Results 1 to 2 of 2
  1. #1
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    256
    Thanks
    6
    Thanked 1 Time in 1 Post

    Question Writing Excel file to SharePoint from Access VBA

    I am stumped. I have this same piece of code in multiple Access databases but in this one it refuses to run.

    Code:
    Function AddToSharePt(SharePointURL As String, MyPath As String, MyFile As String)
        Dim fldR                As Folder
        Dim fsO                 As Scripting.FileSystemObject
        Dim F                   As File
        Dim xmlHTTP
        Dim SharePointFileName
        Dim tsIn
        Dim sBody
        Dim LlFileLength        As Long
        Dim LvarBin()           As Byte
        Dim LobjXML             As Object
        Dim LvarBinData         As Variant
        Dim PstrFullfileName    As String
        Dim PstrTargetURL       As String
        Dim Password            As String
    
        Set LobjXML = CreateObject("Microsoft.XMLHTTP")
        
        Set fsO = CreateObject("Scripting.FileSystemObject")    ' Is this redundant?
       ' sBody = Replace(MyPath, " ", "%20")
        Set fldR = fsO.GetFolder(MyPath)    ' <--- BLOWS up here
        Debug.Print fldR.Files.Count
        
        For Each F In fldR.Files
            
            If F.Name = MyFile Then
            
                SharePointFileName = SharePointURL & F.Name
    Before it got here my program grinds away for 15 minutes creating 2 25meg Excel files.

    In references, I have “Microsoft Scripting Runtime” turned on.

    Anybody got an idea for me??
    Alan

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,938
    Thanks
    4
    Thanked 297 Times in 269 Posts
    What is the value of MyPath? Is that a valid folder path?

    The line looks innocuous enough but if the folder path is not valid then it is going to struggle.
    Last edited by Andrew Lockton; 2017-12-10 at 21:13.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •