我有一些最适合我的机器的代码,因为我有"我的文档" C盘中的目录。现在我已经获得了一台新的笔记本电脑,其中我的宏不起作用,因为这里是D盘中的目录。以下是我的代码: 如果不是ThisWorkbook.Saved然后
If MsgBox("Do you want to save the Output to My Documents?", vbYesNo, "Successful!!") = vbYes Then
ActiveWorkbook.SaveAs Environ$("UserProfile") & "\Documents\" & _
"Abandoned Projects - Bridge Request" & " - " & Format(Date, "(DD-MMM-YY)") & ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
MsgBox "Output is saved to " & "My Documents!", vbInformation, "Finishing..."
End If
End If
我认为" Environ"函数将默认目录作为C驱动器,这是问题所在。我怎样才能做到这一点?
请帮助,我从2天开始尝试这个:(
最佳, Keyur Parekh
答案 0 :(得分:0)
您可以从WScript.Shell.SpecialFolders:
获取此信息Dim docPath As String
With CreateObject("WScript.Shell")
docPath = .SpecialFolders("MyDocuments")
End With
Debug.Print docPath