您好,我试图将xlsm文件保存为我映射到计算机上的服务器上的CSV。
这里是代码:
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
' Store current details for the workbook
SaveToDirectory = "Y:\"
ActiveWorkbook.SaveAs Filename:=SaveToDirectory & "Project_Type_Test" & ".csv", FileFormat:=xlCSV
ActiveWorkbook.Close savechanges:=False
ThisWorkbook.Activate
VBA表示该错误来自这行代码:
ActiveWorkbook.SaveAs Filename:=SaveToDirectory & "Project_Type_Test" & ".csv", FileFormat:=xlCSV
我试图通过ThisWorkbook切换ActiveWorkbook,但它没有改变任何内容。
提前感谢您的帮助!
答案 0 :(得分:0)
我运行了代码,如果我将它设置为我的硬盘,它对我来说很好。
Sub tst()Possibly try using the url instead of the mapped dive letter
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
' Store current details for the workbook
SaveToDirectory = "C:\TEMP\" 'CHANGED THIS TO BE MY HD AND WORKS FINE
ActiveWorkbook.SaveAs Filename:=SaveToDirectory & "Project_Type_Test" & ".csv", FileFormat:=xlCSV
ActiveWorkbook.Close savechanges:=False
ThisWorkbook.Activate
End Sub
可能尝试使用资源的url而不是映射的驱动器号