Experts Exchange connects you with the people and services you need so you can get back to work.
Public Sub open_file()
Const BASEPATH = "G:\Sales\Recon\Results\2014\dd.mm.yyyy.xls"
Dim strGeneratedPath As String
Dim strDay As String
Dim strMonth As String
Dim strYear As String
'swap 2014 with 2015
strGeneratedPath = Replace(BASEPATH, "\2014\", "\2015\")
strDay = Day(Date)
If Len(strDay) < 2 Then strDay = "0" & strDay
strMonth = Month(Date)
If Len(strMonth) < 2 Then strDay = "0" & strMonth
strYear = Year(Date)
strGeneratedPath = Replace(strGeneratedPath, "\dd.", "\" & strDay & ".")
strGeneratedPath = Replace(strGeneratedPath, ".mm.", "." & strMonth & ".")
strGeneratedPath = Replace(strGeneratedPath, ".yyyy.", "." & strYear & ".")
Open in new window
Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.