Results 1 to 4 of 4

Workbooks Loop Run-time error '1004':

Threaded View

trizzo Workbooks Loop Run-time error... 03-26-2015, 09:32 AM
Mad-Mizer Re: Workbooks Loop Run-time... 03-26-2015, 09:38 AM
trizzo Re: Workbooks Loop Run-time... 03-26-2015, 09:39 AM
trizzo Re: Workbooks Loop Run-time... 03-26-2015, 11:55 AM
  1. #1
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Workbooks Loop Run-time error '1004':

    Hello,

    I am looping through workbooks, whenever file name has "CAP CPU" on its file name it opens the Workbook, using the below code:

    
    Sub LoopingFiles_Update()
        Dim StrFile As String
        StrFile = Dir("c:\testfolder\*CAP CPU*")
        Do While Len(StrFile) > 0
            Debug.Print StrFile
            StrFile = Dir
            Application.Workbooks.Open (StrFile)
        Loop
    End Sub

    Here is the error I am getting
    Run-time error '1004':
    Sorry, we couldn't find CAP CPU_New.xlsm. Is it possible it was moved, renamed or deleted?

    I am using Windows 7, and the file is in the correct folder. By looping with F8 I can see StrFile gets the correct file name "CAP CPU_New.xlsm".
    It is strange that it worked twice, now, it is not working anymore.

    Can anyone help me please?

    Thanks!!
    Last edited by trizzo; 03-26-2015 at 09:37 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [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
  2. Run Time Error -'1004' - while copying data between workbooks
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-26-2014, 03:23 AM
  3. Run-time error '1004' for .Refresh BackgroundQuery:=False for loop
    By Robo25 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2013, 01:16 AM
  4. Run time Error 1004 in my Do While loop
    By Kicassrt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-18-2013, 09:27 PM
  5. Array loop producing error "Run time error '1004'"
    By jeskit in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-06-2011, 08:56 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