+ Reply to Thread
Results 1 to 7 of 7

FileLen Syntax Not working for Sharepoint Library url

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    FileLen Syntax Not working for Sharepoint Library url

    Hello,
    I have a template macro which loops through several text files each day and performs some modifications on each and then saves each as an .xlsx file. Occasionally these files are delivered blank or are just missing. I'm trying to screen out these 2 instances and successfully tested 1 option which looks at the size of the file in bytes using FileLen. My code works fine when I test on my local drive using my Temp Folder, but when I update to use a range which captures the sharepoint library url, it fails and gives a "Run time error 5; bad procedure call or argument." The url code itself (in column G) is not bad as I can run the full macro without the FileLen portion. Can anyone guide me as how to overcome this issue? If this is too little information I may be able to attach the full template here.

    FileLen portion of the code is below; column G is the sharepoint library url range and column J is where the FileLen number is populated to.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,310

    Re: FileLen Syntax Not working for Sharepoint Library url

    Does the value in each row of column G contain both the path and file name?

  3. #3
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    Re: FileLen Syntax Not working for Sharepoint Library url

    Yes it does. Each row starts with "https" and ends in ".txt" Also I don't have any spaces in the names of the files stored in this library.

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,310

    Re: FileLen Syntax Not working for Sharepoint Library url

    Checking if the file exists...
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (24 H2) 64 Bit
    Posts
    1,185

    Re: FileLen Syntax Not working for Sharepoint Library url

    Seth_;

    If the files are on a server, then you have to send a request to the server and read the length of the file from the header of the response.

    As an example for you; if the following URLs are on cells A1, A2 and A3

    https://file-examples.com/wp-content...mple_100kB.doc

    https://file-examples.com/wp-content...sample_1MB.doc

    https://file-examples.com/wp-content...ple_500kB.docx


    The following code will get the "File Length" property (i.e. file size) of these files in cells B1, B2 and B3 in "bytes"

    Note: Demo workbook is attached.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Haluk; 07-20-2019 at 05:18 PM.

  6. #6
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    Re: FileLen Syntax Not working for Sharepoint Library url

    Thanks for the response Haluk, I took your code and updated with my particulars (just changed the source and output columns). The code cycled through fine with no errors, but it's outputting "0 bytes" for each file, and all except 1 should be showing data in them. Now these are text files (.txt). Will that make a difference?

  7. #7
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    Re: FileLen Syntax Not working for Sharepoint Library url

    I went ahead and tested on your Test file by just replacing the 3 hyperlinks with 3 of mine and still am getting the "0 bytes" on all of them.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Retrieve SharePoint Document Library weburl path P1
    By hnguy71 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2019, 03:36 PM
  2. Excel Sharepoint New File Library
    By Teddi in forum Excel General
    Replies: 0
    Last Post: 01-30-2019, 07:51 AM
  3. [SOLVED] VBA - Tag of a two-dimensional variable in a SharePoint library
    By Air1_16 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2017, 12:13 PM
  4. VBA to loop through all files in a Sharepoint library/folder
    By red1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2016, 07:09 AM
  5. Sharepoint Excel Document Library Setup
    By Blackbird_71 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-05-2015, 01:14 PM
  6. Macro to save to sharepoint library
    By chris.tinta in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-07-2012, 10:08 PM
  7. #VALUE error when referencing spreadsheet on sharepoint library
    By Lois Johns in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-19-2005, 01:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1