+ Reply to Thread
Results 1 to 6 of 6

Code for open and closing multiple files

  1. #1
    Forum Contributor
    Join Date
    05-27-2014
    Posts
    141

    Code for open and closing multiple files

    Hi All,

    I am struggling with code to open a selection of files based on range 'Control'!B10:D10 but without error so if one of the cells has now file then take no action or error. once they have been opened they are then all closed before the next part of code emails them out.

    Thanks for any input

    Danny
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: Code for open and closing multiple files

    sounds like you should be able to add "on error resume next" anywhere near the top of your code and be good to go...

    i'd caution - it looks like your code is going to try to create 9 extra emails you were not intending
    Set rngEntries = ActiveSheet.Range("B7:D10")
    should probably be
    Set rngEntries = ActiveSheet.Range("B7:D7")
    Last edited by simarui; 04-17-2015 at 02:25 PM.
    Hope I could help - if your post has been solved don't forget to mark it as such.

    Clicking the * below is a great way to say thanks!

    "Drowning in 10 feet of water isn?t any different than drowning in a million feet. And if you can swim, it doesn?t matter how deep the ocean is. At some level, once you realize you?re in water that?s too deep to stand, you have to have a very different approach," - Joi Ito

  3. #3
    Forum Contributor
    Join Date
    05-27-2014
    Posts
    141

    Re: Code for open and closing multiple files

    Hi,

    thanks for that the On Error bit worked and as you said created blank emails, can if statements be used in code so that within the larger range if their was no email listed it would not produce the email. I am just trying to fix the range so it is easier to manage

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Code for open and closing multiple files

    Maybe check if file exist

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Forum Contributor
    Join Date
    05-27-2014
    Posts
    141

    Re: Code for open and closing multiple files

    Hi Mike,

    thank for the input but it just says file not found, in changing the range to B10:D10 it stops the whole email process

  6. #6
    Forum Contributor
    Join Date
    05-27-2014
    Posts
    141

    Re: Code for open and closing multiple files

    I will close this thread and repost as my needs have changed slightly and the code I have now is virtually done.

    Thanks

    All for the Help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Open multiple files and copy data is slow, code after end of loop not working - help?
    By hadamhiram in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2014, 11:52 PM
  2. [SOLVED] Code closing new worksheet.... would like to keep open after naming.
    By floydian in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-16-2013, 11:56 AM
  3. Replies: 1
    Last Post: 04-19-2012, 07:59 PM
  4. Code to open multiple excel files
    By mmf in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2008, 05:40 AM
  5. Replies: 1
    Last Post: 08-03-2006, 12:00 PM

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