文件未保存到VBA中的新建文件夹

时间:2018-07-20 18:28:20

标签: excel vba excel-vba

我有一个宏,该宏通过路径中的数据创建了一个文件夹,并且我希望将经理名册的一部分保存在该文件夹中。由于文件夹名称各不相同,因此该名称必须是动态的。

我希望它像这样:

Dim sPath As String
sPath = "M:\mgr1_TCR_Reports\"
If Len(Dir(sPath & "_" & Format(Date, "mm_dd_yyyy"), vbDirectory)) = 0 Then
 MkDir (sPath & "_" & Format(Date, "mm_dd_yyyy")) 
End If
End Sub

并保存如下:

.SaveAs Filename:="M:\mgr1_TCR_Reports\" & "_" & Format(Date, "mm_dd_yyyy_") & "\" & Manager, FileFormat:=xlOpenXMLWorkbook, Password:=""
 .Close

但是我一直得到运行时1004:文档未保存在我提供的第二行代码的^^^中。

知道发生了什么吗?

0 个答案:

没有答案
相关问题