troubleshooting Question

Open latest file

Avatar of Seamus2626
Seamus2626Flag for Ireland asked on
Microsoft Excel
4 Comments1 Solution291 ViewsLast Modified:
Hi,

I have a file path

H:\Asset Services MI\BSS PACK\ASSET SERVICES\2011\11 NOVEMBER\Corporate Actions

11 NOVEMBER is the part that changes, next month will be 12 DECEMBER then 01 JANUARY etc

I have a sub below, that will open the most recent file in a folder, but i need to adapt it for the above

Thanks
Seamus

Sub CorporateActions()
   
Dim sPath As String, sNew As String
Dim oFSO As Object, oFile As Object, oFldr As Object
Dim DT As Date

Set oFSO = CreateObject("Scripting.FileSystemObject")
sPath = "G:\Asset Services MI\BSS PACK\ASSET SERVICES\2011\Corporate Actions\" & Format(Date, "mmmm") & "\CORPORATE ACTIONS\"
Set oFldr = oFSO.getfolder(sPath)

For Each oFile In oFldr.Files
    If oFile.DateCreated > DT Then
        sNew = oFile.Path
        DT = oFile.DateCreated
    End If
Next oFile

Workbooks.Open sNew
   
End Sub
ASKER CERTIFIED SOLUTION
Rob Henson
Finance Analyst

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros