need to write a code that can open a file which is saved to a common drive a number of times per day using yesterday`s business date with a time stamp. The file format is saved as `FxData2608_09_26.xls`. (09 & 26 are hour and minutes respectively)The problem is that the file is never saved at the same time and I wish to open the first saved file. My code is stuck on the time stamp part of the code which returns current time. If I could have some help on how to solve for the time stamp please. This is my code so far (i am still quite a basic vba user):
Dim Msg, Style, Title, Response
Dim yestdate As Date
Dim dtmdate As Date
Dim filename As String
Dim lastrow As Integer
Dim Numb_row As Integer
Msg = "Are you sure the FX Report has updated?" ' first message
Style = vbYesNo + vbInformation + vbDefaultButton3
Title = "Getting Data"
Response = MsgBox(Msg, Style, Title)
`opens the file excluding weekends
If Response = vbYes Then
yestdate = Format(Date - 1)
'If yestdate=sunday we remove 3 days
If Weekday(yestdate) = 1 Then
yestdate = Format(Date - 3)
Else
yestdate = Format(Date - 1)
End If
'Call Function Bus_Date to check if Business Date
yestdate = Bus_Date.busdate(yestdate)
Application.ScreenUpdating = False
filename = Format(yestdate, "ddmm" & Time, "_Hh_Nn ") & ".xls"
'to open the file for yesterday's business day
Workbooks.Open(filename:="I:\Reports\FXreport" & filename). _
RunAutoMacros Which:=xlAutoOpen
Dim Msg, Style, Title, Response
Dim yestdate As Date
Dim dtmdate As Date
Dim filename As String
Dim lastrow As Integer
Dim Numb_row As Integer
Msg = "Are you sure the FX Report has updated?" ' first message
Style = vbYesNo + vbInformation + vbDefaultButton3
Title = "Getting Data"
Response = MsgBox(Msg, Style, Title)
`opens the file excluding weekends
If Response = vbYes Then
yestdate = Format(Date - 1)
'If yestdate=sunday we remove 3 days
If Weekday(yestdate) = 1 Then
yestdate = Format(Date - 3)
Else
yestdate = Format(Date - 1)
End If
'Call Function Bus_Date to check if Business Date
yestdate = Bus_Date.busdate(yestdate)
Application.ScreenUpdating = False
filename = Format(yestdate, "ddmm" & Time, "_Hh_Nn ") & ".xls"
'to open the file for yesterday's business day
Workbooks.Open(filename:="I:\Reports\FXreport" & filename). _
RunAutoMacros Which:=xlAutoOpen