+ Reply to Thread
Results 1 to 2 of 2

Opening and saving files that have a date in the file name

  1. #1
    Registered User
    Join Date
    01-08-2014
    Location
    Exton, PA
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    3

    Opening and saving files that have a date in the file name

    I'm trying to use VBA (Excel 2013 & Excel 2010) to open an existing worksheet with a file name that contains a date - specifically, the date of the last business day. But I'm having trouble identifying the most efficient way to use VBA to account for weekends and holidays. I've found the WORKDAY function does not work "directly" in VBA, but I've been successful in defining cell formulas in Excel via VBA.

    The following code works when opening and saving files, but does not account for weekends and holidays:

    Please Login or Register  to view this content.
    This code successfully creates a new sheet called "Dates", but does not allow me to open a workbook with a date in the file name.:

    Please Login or Register  to view this content.
    The error I receive reads, "Sorry, we couldn't find 'Q:\Transfer\June\VBA\2014-01-06_Outages.xlsx". Is it possible it was moved, renamed or deleted?" I've confirmed the file does exist, and the original code listed above has no trouble opening the file.

    Is there a tag/command/flag somewhere that I'm missing?

    Thank you!

  2. #2
    Registered User
    Join Date
    01-08-2014
    Location
    Exton, PA
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    3

    Lightbulb Re: Opening and saving files that have a date in the file name

    I've figured out what was wrong! In my second block of code, I had coded an incorrect date format, which is why it couldn't open my existing file (it was looking for 2014-01-06_outages.xlsx instead of 2014-Jan-06_outages.xlsx). Here's the updated code:

    Please Login or Register  to view this content.

+ 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. Saving as pdf files from opening an excel files
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-29-2013, 12:38 AM
  2. Opening files macro help (forcing directory, opening a tsv file)
    By NukedWhale in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2010, 03:07 PM
  3. Opening/saving a file
    By jamjam in forum Excel General
    Replies: 3
    Last Post: 11-30-2007, 08:33 AM
  4. Fix for problem opening/saving files
    By Patricia Shannon in forum Excel General
    Replies: 2
    Last Post: 04-25-2006, 03:40 PM
  5. Opening and Saving Groups of Files
    By NacellesEng in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-16-2005, 12:06 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