+ Reply to Thread
Results 1 to 5 of 5

run time error 1004 method open of object workbooks failed

  1. #1
    Registered User
    Join Date
    03-03-2016
    Location
    nashville, TN
    MS-Off Ver
    2007
    Posts
    24

    run time error 1004 method open of object workbooks failed

    I am getting a run time error when running the script below. The files are located on a SharePoint site. I can open each of the files with no problem so I don't think they are corrupt.
    This line is where the error occurs "Set WorkBk = Workbooks.Open(FolderPath & FileName)"

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: run time error 1004 method open of object workbooks failed

    Does the filename not already include the folderPath?

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: run time error 1004 method open of object workbooks failed

    Try using Open method with URL instead of network path. Open method will accept valid url string as argument.

    And make sure you convert the string to URL type (i.e. replace space with "%20" etc)
    Ex. "http://workspace.bsaconnect.com/fin/AP/NonPO%20Invoices/2017/yourfilename.xlsx"

    You may need to change slash direction. My system uses forward slash, but your's may use back slash.

    Other than that, you can probably add Sharpoint Folder to shared network drive and work with it that way (if it's on same local network).
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: run time error 1004 method open of object workbooks failed

    Does the filename not already include the folderPath?
    Dir should only return file name without path.
    0.JPG

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: run time error 1004 method open of object workbooks failed

    Here is my code for looping through a folder
    http://www.xlorate.com/vba-examples....rough%20Folder

+ 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. Run-time error 1004 Method Open of object Workbooks Failed
    By Rikimaru82 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2016, 04:32 AM
  2. Run Time error 1004 method sheets of object global failed
    By bevc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-27-2016, 04:09 PM
  3. [SOLVED] run-time error '1004' method 'open' of object 'workbooks' failed
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-03-2016, 06:24 PM
  4. run time error 1004 - method range of object worksheet failed.
    By anuwers in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-29-2016, 05:29 PM
  5. [SOLVED] Run-time error '1004': Method 'Open' of object 'Workbooks' failed
    By krish2503 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-14-2015, 06:11 AM
  6. Run-Time Error 1004 Method Range of object _Global Failed?
    By MadDino in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-11-2011, 05:13 AM
  7. [SOLVED] Run-time error 1004: Method 'Axes' of object '_chart' failed
    By Brian Morrison in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-20-2005, 11:05 AM

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