+ Reply to Thread
Results 1 to 3 of 3

File does not exist

  1. #1
    Judd Jones
    Guest

    File does not exist

    I have a macro that opens a workbook off of my server.
    I am wanting to be able to display a dialog box that says that the file does
    not exist and then goto to the end of the macro. As is now I get a runtime
    error '1004' and you have to end the macro or debug it. I don't want the user
    to see this error message.

    Here is the code that opens the workbook:
    Set destWB = Workbooks.Open("X:\Projects\Group 17 (McLendon)\Group 17
    Dayrates\" & wName)


  2. #2
    Bob Phillips
    Guest

    Re: File does not exist


    Set destWB = Nothing 'jsut to be sure
    On ERrror Resume Next
    Set destWB = Workbooks.Open("X:\Projects\Group 17 (McLendon)\Group 17
    Dayrates\" & wName)
    On Error Goto 0
    If destWB Is Nothing Then
    Msgbox "File does not exist
    Exit SUb
    End IF

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Judd Jones" <[email protected]> wrote in message
    news:[email protected]...
    > I have a macro that opens a workbook off of my server.
    > I am wanting to be able to display a dialog box that says that the file

    does
    > not exist and then goto to the end of the macro. As is now I get a runtime
    > error '1004' and you have to end the macro or debug it. I don't want the

    user
    > to see this error message.
    >
    > Here is the code that opens the workbook:
    > Set destWB = Workbooks.Open("X:\Projects\Group 17 (McLendon)\Group 17
    > Dayrates\" & wName)
    >




  3. #3
    Tom Ogilvy
    Guest

    Re: File does not exist

    sStr = "X:\Projects\Group 17 (McLendon)\Group 17 Dayrates\"
    if Dir(sStr & wName) = "" then
    msgbox wName & " doesn't exist in " & sStr
    exit sub
    End if
    Set destWB = Workbooks.Open & wName)

    --
    Regards,
    Tom Ogilvy

    "Judd Jones" <[email protected]> wrote in message
    news:[email protected]...
    > I have a macro that opens a workbook off of my server.
    > I am wanting to be able to display a dialog box that says that the file

    does
    > not exist and then goto to the end of the macro. As is now I get a runtime
    > error '1004' and you have to end the macro or debug it. I don't want the

    user
    > to see this error message.
    >
    > Here is the code that opens the workbook:
    > Set destWB = Workbooks.Open("X:\Projects\Group 17 (McLendon)\Group 17
    > Dayrates\" & wName)
    >




+ 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