+ Reply to Thread
Results 1 to 9 of 9

Micro that checks if file exists

Hybrid View

  1. #1
    pete
    Guest

    Micro that checks if file exists

    Hi, everyone.
    I have a micro that opens other files to copy data to this file. How can I
    make it to skip a file that does not exist and continue to the next one?

    Thanks for your help.

  2. #2
    Bob Phillips
    Guest

    Re: Micro that checks if file exists


    Set thisFile = Workbooks.Open("filename")
    If Not thisFile Is Nothing Then
    'your code
    Else
    'get the next
    End If

    --

    HTH

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


    "pete" <pete@discussions.microsoft.com> wrote in message
    news:DA3817B9-955A-4FC5-941D-5CCCC09287DB@microsoft.com...
    > Hi, everyone.
    > I have a micro that opens other files to copy data to this file. How can

    I
    > make it to skip a file that does not exist and continue to the next one?
    >
    > Thanks for your help.




  3. #3
    pete
    Guest

    Re: Micro that checks if file exists

    Bob,

    Thanks for your clue. I still have a problem; if the file does not exist, I
    have the "run-time error 1004" which terminates the macro because it will not
    allow me to continue.

    Anything else I need to add so I if it cannot find the file, it will go to
    the next one?

    Thanks,
    Pete

  4. #4
    Bob Phillips
    Guest

    Re: Micro that checks if file exists

    Sorry, it shoule be error wrapped

    On Error Resume Next
    Set thisFile = Workbooks.Open("filename")
    On Error Goto 0
    If Not thisFile Is Nothing Then
    'your code
    Else
    'get the next
    End If


    --

    HTH

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


    "pete" <pete@discussions.microsoft.com> wrote in message
    news:EF3DACF5-C9AA-4EDA-A240-6153C115F2FB@microsoft.com...
    > Bob,
    >
    > Thanks for your clue. I still have a problem; if the file does not exist,

    I
    > have the "run-time error 1004" which terminates the macro because it will

    not
    > allow me to continue.
    >
    > Anything else I need to add so I if it cannot find the file, it will go to
    > the next one?
    >
    > Thanks,
    > Pete




  5. #5
    pete
    Guest

    Re: Micro that checks if file exists

    Thanks again, Bob, for your timely fix. I almost got it, except the "Go to 0".
    What can I substitute for "0"?

  6. #6
    Myrna Larson
    Guest

    Re: Micro that checks if file exists

    If you are talking about On Error Goto 0, that statement turns error trapping
    off. If you mean a standard Goto statement (yes, it's still around), you have
    to set up line numbers/labels and use those in your Goto statements.

    On Wed, 23 Mar 2005 13:37:02 -0800, "pete" <pete@discussions.microsoft.com>
    wrote:

    >Thanks again, Bob, for your timely fix. I almost got it, except the "Go to

    0".
    >What can I substitute for "0"?



+ 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