exploringex
03-04-2016, 02:21 PM
Hi, the macro keeps giving me "run-time error 13". the highlighted in green has issue. I don't know how to resolve it. I need the file name in "yyyymmdd" date format. could anyone help. Thanks
Dim strLocation As String
Dim FolderYear As String
Dim FolderMonthYear As String
Dim FileDate As String
Dim FileDate2, FileDate3, FileDate4 As String
Dim FileDate5, FileDate6, FileDate7 As String
Dim FileDateSubject As Date
Dim UserName, Contact_Info As String
Dim a As String
FolderYear = Format(Now(), "yyyy")
FolderMonthYear = Format(Now(), "mm-yyyy")
FileDate = Format(Now(), "yyyymmdd")
FileDateSubject = Format(Now(), "mm/dd/yyyy")
FileDateSubject = DateAdd("d", 1, FileDate) 'Green highlight here. SamT
FileDate2 = Format(DateAdd("d", 1, FileDate))
FileDate3 = Replace(FileDate2, "/", "-") 'replace slashes with dashes
FileDate4 = Format(FileDateSubject, "yyyymmdd") 'change File Date to format "yyyymmdd"
If IsWeekend(FileDate4) = True Then FileDate4 = DateAdd("d", 3, FileDate) 'weekend test
FileDate6 = FileDate4
FileDate6 = Replace(FileDate4, "/", "-")
FileDate7 = Format(FileDate4, "mm-dd-yy")
FileDate4 = FileDate7
FolderMonthYear = Format(FileDate4, "mm-yyyy")
Dim strLocation As String
Dim FolderYear As String
Dim FolderMonthYear As String
Dim FileDate As String
Dim FileDate2, FileDate3, FileDate4 As String
Dim FileDate5, FileDate6, FileDate7 As String
Dim FileDateSubject As Date
Dim UserName, Contact_Info As String
Dim a As String
FolderYear = Format(Now(), "yyyy")
FolderMonthYear = Format(Now(), "mm-yyyy")
FileDate = Format(Now(), "yyyymmdd")
FileDateSubject = Format(Now(), "mm/dd/yyyy")
FileDateSubject = DateAdd("d", 1, FileDate) 'Green highlight here. SamT
FileDate2 = Format(DateAdd("d", 1, FileDate))
FileDate3 = Replace(FileDate2, "/", "-") 'replace slashes with dashes
FileDate4 = Format(FileDateSubject, "yyyymmdd") 'change File Date to format "yyyymmdd"
If IsWeekend(FileDate4) = True Then FileDate4 = DateAdd("d", 3, FileDate) 'weekend test
FileDate6 = FileDate4
FileDate6 = Replace(FileDate4, "/", "-")
FileDate7 = Format(FileDate4, "mm-dd-yy")
FileDate4 = FileDate7
FolderMonthYear = Format(FileDate4, "mm-yyyy")