Hi all,
I have two functions that I routinely use to check for the existence of paths to files ... I am attempting to debug another sub, and so was trying to compile my entire project in the hope of finding flaws in my code. In the block below, I am receiving a warning "Compile Error: ByRef argument type mismatch".
I am confident the cause of the issue is the calls to the date and time functions, but these functions usually work? Also, how can I rewrite the strings/function so that I can address this issue? Any help appreciated?
Here is the code that is breaking: (on "Call CheckForPaths(archivePath1,...)")
And here are the functions:
I have two functions that I routinely use to check for the existence of paths to files ... I am attempting to debug another sub, and so was trying to compile my entire project in the hope of finding flaws in my code. In the block below, I am receiving a warning "Compile Error: ByRef argument type mismatch".
I am confident the cause of the issue is the calls to the date and time functions, but these functions usually work? Also, how can I rewrite the strings/function so that I can address this issue? Any help appreciated?
Here is the code that is breaking: (on "Call CheckForPaths(archivePath1,...)")
Code:
Dim archivePath1, archivePath2, archivePath3, archivePath4, archivePath5 As String
archivePath1 = "C:\\Users\Alex\DB\Extracts\" & Year(Now) & "\"
archivePath2 = archivePath1 & MonthName(Month(Now)) & "\"
archivePath3 = archivePath2 & "Extract_File " & Format(Now(), "yyyymmdd.hhnnss") & ".xlsx"
Call CheckForPaths(archivePath1, archivePath2)
Call CheckForPath(archivePath3)
And here are the functions:
Code:
Public Sub CheckForPaths(sPath1 As String, sPath2 As String)
If Len(Dir(sPath1, vbDirectory)) = 0 Then
MkDir (sPath1)
End If
If Len(Dir(sPath2, vbDirectory)) = 0 Then
MkDir (sPath2)
End If
End Sub
Public Sub CheckOnePath(sPath3 As String)
If Len(Dir(sPath3, vbDirectory)) = 0 Then
MkDir (sPath3)
End If
End Sub