year = 2013
month = MonthName(1)
'I have also tried just putting "January" in there as well
这有效:
Path1 = "\\TEST\" & year & "\"
但这不是:
Path1 = "\\TEST\" & year & "\" & month & "\"
连连呢?谢谢!
最终修复:
将Path1拆分为:
Path1: "\\TEST\" & year & "\"
Path2: "\\TEST\" & year & "\" & month & "\"
检查:
If Len(Dir(Path1, vbDirectory)) = 0 Then
MkDir Path1
End If
If Len(Dir(Path2, vbDirectory)) = 0 Then
MkDir Path2
End If
答案 0 :(得分:2)
除非"\\TEST\" & year & "\" & month & "\"
已存在,否则无法通过MkDir创建"\\TEST\" & year & "\"
。
扩展您发布的代码,您可以这样做:
Path1 = "\\TEST\" & year & "\"
If DIR$(Path1, vbDirectory) <> "" then mkdir Path1
Path1 = "\\TEST\" & year & "\" & month & "\"
If DIR$(Path1, vbDirectory) <> "" then mkdir Path1