Results 1 to 12 of 12

Open file when file path contains dates

Threaded View

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    68

    Open file when file path contains dates

    Hi all,

    Having an issue getting the correct logic to open a file path that changes each month and year, examples below and start of effort.

    I am checking if the file exists, and if so, then open

    The date at the end of the path needs to be fool proof, so 8 July (d mmm) as well as 08 July (dd mmm)

    The FY20 stands for Full Year 2020 which changes monthly, i.e. we are in July now.

    K:\Reconciliation Team\client\Year Ending 2019\FY19 July 19\BOI\8 July 19
    K:\Reconciliation Team\client\Year Ending 2019\FY19 July 19\BOI\28 July 19
    K:\Reconciliation Team\client\Year Ending 2020\FY20 Jan 20\BOI\8 Jan 20
    Dim wbCopy As Workbook
    Dim TDate As Date
    
    Dim wbMe As Workbook
    Dim trans As Integer
    Set wbMe = ThisWorkbook
    
    
    Dim OHS As String
    OHS = ""
    
    On Error Resume Next
    
    TDate = Date
    
    Select Case Weekday(TDate)
    
    Case vbMonday
        TDate = TDate - 3
        End Select
    
    'OHS = "K:\Reconciliation Team\client\Year Ending 2019\FY19 July 19\BOI\8 July 19\312 - EPFX Postings\BalanceAndTransactionReport.csv"")"
    
    OHS = "K:\Reconciliation Team\client\Year Ending 2019\FY19 July 19\BOI\format (tdate, dd mmm yy)\312 - EPFX Postings\BalanceAndTransactionReport.csv"")"
    
    On Error GoTo 0
    If OHS = "" Then
    
    MsgBox "EP report does not exist"
    
    Exit Sub
    
    End If
    Application.DisplayAlerts = False
        
    
    Set wbCopy = Workbooks.Open("K:\Reconciliation Team\Baydonhill\Year Ending 2019\FY19 July 19\BOI\format (date, dd mmm yy)\312 - EPFX Postings\BalanceAndTransactionReport.csv")


    Thanks for the help in advance
    Last edited by heathb; 07-09-2019 at 11:05 AM. Reason: Cannot reply

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Using Workbook.Open to open an excel file with a variable path
    By walt737 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2019, 01:01 PM
  2. Automatically open a file in a specific file path when another sheet is opened
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2014, 11:05 AM
  3. Replies: 5
    Last Post: 09-29-2012, 12:40 PM
  4. VBA Changing a fixed file path with open file dialog box
    By Dan27 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2011, 08:54 AM
  5. open file path
    By Bigelk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2011, 09:00 AM
  6. Open Word file form Excel using VBA and file path
    By psychoPETE in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-05-2010, 07:02 PM
  7. Saving file to same path as open file
    By Glio in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-19-2007, 04:57 AM

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