Results 1 to 7 of 7

DIR command returns Bad file name or number error

Threaded View

longandtallpaul DIR command returns Bad file... 10-18-2018, 03:34 PM
6StringJazzer Re: DIR command returns Bad... 10-18-2018, 04:27 PM
longandtallpaul Re: DIR command returns Bad... 10-18-2018, 04:41 PM
6StringJazzer Re: DIR command returns Bad... 10-18-2018, 05:41 PM
longandtallpaul Re: DIR command returns Bad... 10-18-2018, 04:56 PM
Zer0Cool Re: DIR command returns Bad... 10-18-2018, 04:58 PM
longandtallpaul Re: DIR command returns Bad... 10-18-2018, 05:03 PM
  1. #1
    Registered User
    Join Date
    10-18-2018
    Location
    London
    MS-Off Ver
    2016
    Posts
    4

    DIR command returns Bad file name or number error

    Hi,

    I have a few lines of code which check to see if a file exists on our sharepoint and then if it doesn't it gives a message and closes the macro or if it does exist it opens the file. I get a run time error on the DIR part of the code. The workbooks.open code works fine on its own so the file path is ok. The DIR part of the code does work if I first go into the sharepoint and open the folder, then the code works fine. Then if I close excel and re open the code doesn't work again. Is there an alternative I can use instead of DIR to find out if a file exists or another idea? I've replaced the actual sharepoint file path with the words sharepoint address and folders etc

    Dim Pablo_Sourcer_File_Path
    
    Pablo_Sourcer_File_Path = "\\sharepoint address and folders etc\Tracker.xlsx"
    
    if Dir(Pablo_Sourcer_File_Path) = "" Then
    msgbox("File not on sharepoint")
    exit sub
    end if
    
    workbooks.open Pablo_Sourcer_File_Path
    Last edited by Leith Ross; 10-18-2018 at 04:09 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Kill command & Path/File access error (Error 75)
    By bongaan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-06-2021, 08:21 PM
  2. Replies: 0
    Last Post: 11-15-2016, 02:38 PM
  3. WorksheetFunction.Match returns error with String variable, but not with number
    By IntisarN in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-20-2015, 03:38 PM
  4. Replies: 1
    Last Post: 05-07-2014, 07:05 AM
  5. [SOLVED] How to stop error when I cancel the input file source command?
    By XxCMoneyxX in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-15-2013, 03:23 PM
  6. returns covariance MMULT command
    By marco2011 in forum Excel General
    Replies: 0
    Last Post: 04-07-2010, 01:47 AM
  7. Kill Command - file not found error
    By chris100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2010, 02:55 PM

Tags for this Thread

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