+ Reply to Thread
Results 1 to 6 of 6

Bypassing Runtime Error 1004

Hybrid View

janjan_376 Bypassing Runtime Error 1004 08-12-2009, 03:18 PM
shg Re: Bypassing Runtime Error... 08-12-2009, 03:36 PM
janjan_376 Re: Bypassing Runtime Error... 08-14-2009, 12:28 PM
shg Re: Bypassing Runtime Error... 08-14-2009, 04:16 PM
janjan_376 Re: Bypassing Runtime Error... 08-17-2009, 03:02 PM
shg Re: Bypassing Runtime Error... 08-17-2009, 03:30 PM
  1. #1
    Forum Contributor
    Join Date
    07-22-2008
    Location
    canada
    Posts
    123

    Bypassing Runtime Error 1004

    ChDir "C:\dir1"
    Workbooks.Open Filename:="C:\dir1\file1.xls"
    .....

    I need help on the above formula. I would like to add a condition such as IF file1.xls does not exist continue on the next line without getting the "Runtime Error 1004"

    Thank you.
    Last edited by janjan_376; 08-17-2009 at 03:01 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Bypassing Runtime Error 1004

    Please edit your post to add code tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    07-22-2008
    Location
    canada
    Posts
    123

    Re: Bypassing Runtime Error 1004

    I have added the code tags please let me know if it worked. Thank you.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Bypassing Runtime Error 1004

    Nope. The forum rules explain how ...

  5. #5
    Forum Contributor
    Join Date
    07-22-2008
    Location
    canada
    Posts
    123

    Re: Bypassing Runtime Error 1004

    I added the right code. Please help on my runtime error

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Bypassing Runtime Error 1004

    Thanks.

    Try this:
        Const sFile As String = "C:\dir1\file1.xls"
        
        If Len(Dir(sFile)) Then
            Workbooks.Open Filename:=sFile
        Else
            MsgBox "File """ & sFile & """ does not exist"
            Exit Sub
        End If

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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