嗨我将在保存完成后弹出文件位置文件夹。我的问题是当我取消保存。该文件夹也弹出。单击取消保存时如何停止文件夹弹出。如果我没有弄错,可以通过退出声明
来完成这里是我的代码
Private Sub savebr_Click()
Dim varResult As Variant
Dim saveas As String
Dim fname As String
Cells.AutoFilter
'to get original filename put below code
fname = ActiveWorkbook.Name
saveas = "C:/newfolder.Show fname
'to open targeted folder after save
Call Shell("explorer.exe" & " " & ActiveWorkbook.path, vbNormalFocus)
End Sub
答案 0 :(得分:1)
打开你的vbe窗口。转到ThisWorkbook。
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
If (Success) Then
Call Shell("explorer.exe" & " " & ActiveWorkbook.Path, vbNormalFocus)
End If
End Sub
使用普通保存方法保存后,此宏将打开该文件夹。
**更新了用户取消保存的时间。