Public Function PrintF(strMask As String, ParamArray Values()) As String On Error Resume Next Dim lngNbrValues As Long, lngCount As Long Dim strX As String, strFind As String lngNbrValues = UBound(Values) strX = Replace(strMask, "\\", "¥¥¥") strX = Replace(strX, "\t", vbTab) strX = Replace(strX, "\n", vbNewLine) For lngCount = lngNbrValues To 0 Step -1 strFind = "\{" + CStr(lngCount) + "}" strX = Replace(strX, strFind, Values(lngCount)) strFind = "\" + CStr(lngCount) strX = Replace(strX, strFind, Values(lngCount)) Next lngCount
strX = Replace(strX, "¥¥¥", "\") PrintF = strX On Error GoTo 0 End Function
Public Function GenerateNewFilename(strFilename As String) As String Dim strNew As String Dim dteNow As Date dteNow = Now()
strNew = PrintF("_\0\1\2_\3\4\5_" + strFilename, Format(CStr(Year(dteNow)), _ "0000"), Format(CStr(Month(dteNow)), "00"), Format(CStr(Day(dteNow)), _ "00"), Format(CStr(Hour(dteNow)), "00"), Format(CStr(Minute(dteNow)), _ "00"), Format(CStr(Second(dteNow)), "00")) GenerateNewFilename = strNew End Function
|