+ Reply to Thread
Results 1 to 3 of 3

Preventing import code from stopping when it can't find a file

  1. #1
    Registered User
    Join Date
    12-07-2006
    Posts
    36

    Question Preventing import code from stopping when it can't find a file

    Hi.

    I'm using code to import images into an Excel worksheet as objects.
    The code looks like this:
    Please Login or Register  to view this content.
    But whenever this code is asked to import a filename that does not exist, the program stops and an error message comes up:

    Run-time error '1004'
    Cannot insert object

    Is is possible to prevent the VBA code from stopping if there is no file which has the right filename?
    I would like the code to just ignore the missing file and look for the next filename that's fed into it.

    Thanks in advance for your help.
    Last edited by VBA Noob; 07-13-2007 at 09:42 AM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    You can try with this code:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    12-07-2006
    Posts
    36
    Thanks for your help, Antonio.

    I will try out the code you suggest.

+ 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